diff --git a/default/Makefile.am b/default/Makefile.am index 88d97d6f5..e9169017f 100644 --- a/default/Makefile.am +++ b/default/Makefile.am @@ -189,7 +189,6 @@ nobase_default_DATA = \ web_tt2/arcsearch.tt2 \ web_tt2/arc.tt2 \ web_tt2/aside_menu.tt2 \ - web_tt2/auto_signoff.tt2 \ web_tt2/automatic_lists_management_request.tt2 \ web_tt2/automatic_lists_request.tt2 \ web_tt2/automatic_lists.tt2 \ @@ -298,13 +297,13 @@ nobase_default_DATA = \ web_tt2/show_exclude.tt2 \ web_tt2/show_sessions.tt2 \ web_tt2/sigindex.tt2 \ - web_tt2/sigrequest.tt2 \ + web_tt2/signoff.tt2 \ web_tt2/skinsedit.tt2 \ web_tt2/sso_login.tt2 \ web_tt2/stats.tt2 \ web_tt2/subindex.tt2 \ web_tt2/suboptions.tt2 \ - web_tt2/subrequest.tt2 \ + web_tt2/subscribe.tt2 \ web_tt2/subscriber_table.tt2 \ web_tt2/suspend_request.tt2 \ web_tt2/sympa_menu.tt2 \ diff --git a/default/mail_tt2/command_report.tt2 b/default/mail_tt2/command_report.tt2 index 551cf22ba..b45b65fd8 100644 --- a/default/mail_tt2/command_report.tt2 +++ b/default/mail_tt2/command_report.tt2 @@ -31,6 +31,9 @@ X-Loop: [% conf.email %]@[% conf.host %] [% ELSIF notice.entry == 'sent_to_owner' -%] [%|loc%]Your request to subscribe/unsubscribe has been forwarded to the list's owners for approval. You will receive a notification when you have been subscribed (or unsubscribed) to the list.[%END-%] +[% ELSIF notice.entry == 'sent_to_user' -%] +[%|loc%]To confirm your identity and prevent anyone from subscribing you to this list against your will, a message containing an validation link was sent to the e-mail address you provided.[%END%] + [% ELSIF notice.entry == 'updated_info' -%] [%|loc(notice.email,notice.listname)%]Information regarding user %1 has been updated for list %2.[%END%] diff --git a/default/mail_tt2/invite.tt2 b/default/mail_tt2/invite.tt2 index 4a1e49c6a..c0bdd3f56 100644 --- a/default/mail_tt2/invite.tt2 +++ b/default/mail_tt2/invite.tt2 @@ -6,11 +6,15 @@ Subject: [% FILTER qencode %][%|loc(list.name)%]Invitation to join list %1[%END% [%|loc(list.subject)%]This list is about %1, so you are probably concerned.[%END%] [%|loc%]To subscribe just hit the following link:[%END%] +[% IF user_interfaces.size() == 1 && user_interfaces.0 == 'mail' -%] [% | mailtourl({subject => "AUTH ${keyauth} ${cmd}"}) ~%] [% conf.email %]@[% conf.host %] [%~ END %] [%|loc(conf.email,conf.host)%]Or send a message to %1@%2 with the following subject:[%END%] AUTH [% keyauth %] [% cmd %] +[%- ELSE -%] + [% 'auth' | url_abs([keyauth,'subscribe'],{email=>user.email}) %] +[%- END %] [%|loc%]If you don't want to subscribe just ignore this message.[%END%] diff --git a/default/mail_tt2/listowner_notification.tt2 b/default/mail_tt2/listowner_notification.tt2 index 57cdbf1ea..edc5401ed 100644 --- a/default/mail_tt2/listowner_notification.tt2 +++ b/default/mail_tt2/listowner_notification.tt2 @@ -49,17 +49,15 @@ Subject: [% FILTER qencode %][%|loc(list.name)%]Subscription request to list %1[ [%|loc(list.name)-%]Dear owner of list %1, -A user asked to be added as a subscriber to your list. In order to list and manage pending subscription requests you should click on the following link:[%END%] +A user asked to be added as a subscriber to your list. If this is OK with you, you should click on the following link:[%END%] +[% IF user_interfaces.size() == 1 && user_interfaces.0 == 'mail' -%] + [% "${conf.email}@${conf.host}" | mailtourl({subject=>"AUTH ${keyauth} ADD ${list.name} ${who} ${gecos}"}) %] -[% 'ticket' | url_abs([one_time_ticket]) %] - -[%|loc("${conf.email}@${conf.host}")%]If prefered, you can accept this subscription request sending an email to %1 with the following subject:[%END%] -AUTH [%keyauth%] ADD [%list.name%] [%who%] [%gecos%] - -[%|loc%]That can be done using this mailto link:[%END%] -[% | mailtourl({subject => "auth ${keyauth} ADD ${list.name} ${who} ${gecos}"}) ~%] - [% conf.email %]@[% conf.host %] -[%~ END %] +[%|loc(conf.email,conf.host)%]Or send a message to %1@%2 with the following subject:[%END%] + AUTH [%keyauth%] ADD [%list.name%] [%who%] [%gecos%] +[%- ELSE -%] + [% 'auth' | url_abs([keyauth,'add',list.name],{email=>user.email}) %] +[%- END %] [% IF custom_attribute %] [%|loc%]The user has provided the following informations:[%END%] @@ -74,16 +72,14 @@ Subject: [% FILTER qencode %][%|loc(list.name)%]UNsubscription request from list [%|loc(list.name)-%]Dear owner of list %1, A user asked to be deleted from your list. If this is OK with you, you should click on the following link:[% END %] - -[% 'ticket' | url_abs([one_time_ticket]) %] +[% IF user_interfaces.size() == 1 && user_interfaces.0 == 'mail' -%] + [% "${conf.email}@${conf.host}" | mailtourl({subject=>"AUTH ${keyauth} DEL ${list.name} ${who}"}) %] [%|loc(conf.email,conf.host)%]Or send a message to %1@%2 with the following subject:[%END%] -AUTH [%keyauth%] DEL [%list.name%] [%who%] - -[%|loc%]That can be done using this mailto link:[%END%] -[% | mailtourl({subject => "auth ${keyauth} DEL ${list.name} ${who}"}) ~%] - [% conf.email %]@[% conf.host %] -[%~ END %] + AUTH [%keyauth%] DEL [%list.name%] [%who%] +[%- ELSE -%] + [% 'auth' | url_abs([keyauth,'del',list.name],{email=>user.email}) %] +[%- END %] [% ELSIF type == 'automatic_bounce_management' -%] [% PROCESS 'automatic_bounce_management.tt2' -%] diff --git a/default/mail_tt2/request_auth.tt2 b/default/mail_tt2/request_auth.tt2 index 8038a5610..0e297b9a3 100644 --- a/default/mail_tt2/request_auth.tt2 +++ b/default/mail_tt2/request_auth.tt2 @@ -1,27 +1,40 @@ [%# request_auth.tt2 ~%] To: [% to %] +[% IF user_interfaces.size() == 1 and user_interfaces.0 == 'mail' -%] Subject: [% FILTER qencode %]AUTH [%keyauth%] [%cmd%][%END%] +[%- ELSIF type == 'signoff' -%] +Subject: [% FILTER qencode %][%|loc(conf.title,list.name)%]%1 / unsubscribing from %2[%END%][%END%] +[%- ELSIF type == 'subscribe' -%] +Subject: [% FILTER qencode %][%|loc(conf.title,list.name)%]%1 / subscribing to %2[%END%][%END%] +[%- ELSE -%] +Subject: [% FILTER qencode %]AUTH [%keyauth%] [%cmd%][%END%] +[%- END %] - [% IF type == 'signoff' -%] +[% IF type == 'signoff' -%] [%|loc(list.name)-%]You asked for your e-mail address to be removed from list '%1'.[%- END -%] - [%- ELSIF type == 'subscribe' -%] +[%- ELSIF type == 'subscribe' -%] [%|loc(list.name)-%]You asked for your e-mail address to be added to list '%1'.[%- END -%] - [%- ELSIF type == 'add' -%] +[%- ELSIF type == 'add' -%] [%|loc(list.name)-%]You requested a user subscription in list %1.[%- END -%] - [%- ELSIF type == 'del' -%] +[%- ELSIF type == 'del' -%] [%|loc(list.name)-%]You requested a user removal from list %1.[%- END -%] - [%- ELSIF type == 'remind' -%] +[%- ELSIF type == 'remind' -%] [%|loc(list.name)-%]You requested a subscription reminder to be sent to each subscriber of list %1[%- END -%] - [%- ELSIF type == 'global_remind' -%] +[%- ELSIF type == 'global_remind' -%] [%|loc-%]You requested a subscription reminder to be sent to each subscriber of list '*'[%- END -%] -[%- END -%] -[% sympa = BLOCK %][% conf.email %]@[% conf.host %][%END%] +[%- ELSE -%] +[%|loc(type)%]You requested an action '%1'.[% END -%] + +[%- END -%] + +[% IF user_interfaces.size() == 1 and user_interfaces.0 == 'mail' -%] +[% sympa = BLOCK %][% conf.email %]@[% conf.host %][%END -%] [%|loc(sympa,"AUTH ${keyauth} ${cmd}") %]If you want this action to be taken, please - reply to this mail @@ -30,8 +43,10 @@ OR %2 OR - hit the following mailto[% END %] - [% | mailtourl({subject => "AUTH ${keyauth} ${cmd}"}) ~%] - [% conf.email %]@[% conf.host %] - [%~ END %] + [% sympa | mailtourl({subject => "AUTH ${keyauth} ${cmd}"}) %] +[%- ELSE -%] +[%|loc%]If you want this action to be taken, please hit the following link:[%END%] + [% 'auth' | url_abs([keyauth,type],{email=>to}) ~%] +[%- END %] [%|loc-%]If you do not want this action to be taken, you can safely ignore this message.[% END %] diff --git a/default/mail_tt2/sendpasswd.tt2 b/default/mail_tt2/sendpasswd.tt2 index 8fba6e6ee..0e2ef5844 100644 --- a/default/mail_tt2/sendpasswd.tt2 +++ b/default/mail_tt2/sendpasswd.tt2 @@ -1,34 +1,10 @@ [%# sendpasswd.tt2 ~%] To: [% newuser.email %] -[% IF action == 'subrequest' -%] -Subject: [% FILTER qencode %][%|loc(conf.title,list)%]%1 / subscribing to %2[%END%][%END%] -[% ELSIF action == 'sigrequest' -%] -Subject: [% FILTER qencode %][%|loc(conf.title,list)%]%1 / unsubscribing from %2[%END%][%END%] -[% ELSE -%] Subject: [% FILTER qencode %][%|loc(conf.title)%]%1 / your environment[%END%][%END%] -[% END -%] - -[% IF action == 'subrequest' -%] - -[%# A parameter request_from_host may be used to show remote host. - However, use it carefully. ~%] -[%|loc(list,conf.host)%]Someone, probably you, requested to subscribe to list %1@%2.[%END%] -[%|loc%]You may ignore this subscription request or click on the following link in order to confirm it [%END%]: [% 'ticket' | url_abs([one_time_ticket]) %] - -[% ELSIF action == 'sigrequest' -%] -[%|loc(list)%]You asked to be unsubscribed from %1 mailing list.[%END%] - -[%|loc%]To unsubscribe from the list, you need to provide the following password[%END%] - - [%|loc(newuser.password)%]password: %1[%END%] - -[% ELSE -%] [%# A parameter request_from_host may be used to show remote host. However, use it carefully. ~%] [%|loc(conf.host)%]Someone, probably you, requested to allocate or renew your password for your list server account %1.[%END%] [%|loc%]You may ignore this request or click on the following link in order to choose your password. [%END%]: [% 'ticket' | url_abs([one_time_ticket]) %] -[%END%] - [%|loc(conf.wwsympa_url,'/help')%]Help on Sympa: %1%2[%END%] diff --git a/default/mail_tt2/user_notification.tt2 b/default/mail_tt2/user_notification.tt2 index 348b8a727..d6a3bb4e5 100644 --- a/default/mail_tt2/user_notification.tt2 +++ b/default/mail_tt2/user_notification.tt2 @@ -41,17 +41,6 @@ Subject: [% FILTER qencode %][%|loc%]Changing your subscriber email address[%END [%|loc%]You have requested to change your subscriber email address. To confirm your new email address with the SYMPA server, please click the link below:[%END%] [% 'ticket' | url_abs([one_time_ticket]) %] - -[% ELSIF type == 'ticket_to_signoff' -%] -Subject: [% FILTER qencode %][%|loc(list.name)%]Unsubscribing from list %1[%END%][%END%] -[% IF context == 'auto_signoff'%] -[%|loc(list.name,ip)%]Somebody (probably you) requested to unsubscribe you from list %1. This query was issued from the IP number '%2'. -To confirm and get removed from the list, please click the link below: [%END%] -[% ELSE %] -[%|loc(list.name)%]You have requested to be removed from list %1. To confirm and get removed from the list, please click the link below: [%END%] -[% END %] - [% 'ticket' | url_abs([one_time_ticket]) %] - [% ELSIF type == 'ticket_to_family_signoff' -%] Subject: [% FILTER qencode %][%|loc(family)%]Unsubscribing from family %1[%END%][%END%] [% IF context == 'family_signoff'%] diff --git a/default/web_tt2/auto_signoff.tt2 b/default/web_tt2/auto_signoff.tt2 deleted file mode 100644 index 422f032b1..000000000 --- a/default/web_tt2/auto_signoff.tt2 +++ /dev/null @@ -1,3 +0,0 @@ -
[%|loc(signing_off_email,list)%]You clicked a link to unsubscribe the address %1 from list %2.[% END %]
-[%|loc(list)%]A confirmation was just sent to this address. By clicking the link it contains, you will be definitively unsubscribed from list %1[% END %]
diff --git a/default/web_tt2/confirm_action.tt2 b/default/web_tt2/confirm_action.tt2 index 40e913f20..0d240d5e1 100644 --- a/default/web_tt2/confirm_action.tt2 +++ b/default/web_tt2/confirm_action.tt2 @@ -25,6 +25,25 @@[%|loc%]Do you really want to delete Selected Archives?[%END%]
+[%~ ELSIF confirm_action == 'auth' ~%] ++ [%|loc%]Do you really want this action to be taken?[%END%] +
[%~ ELSIF confirm_action == 'close_list' ~%][%|loc%]This button aims at protecting mailing lists archives against Spam Harvester.[%END%]
+[%~ ELSIF confirm_action == 'auth' ~%] ++ [% IF notice.action == 'auto_signoff' ~%] +
[%|loc(email,list)%]You clicked a link to unsubscribe the address %1 from list %2.[% END %]
+[%|loc(list)%]A confirmation was just sent to this address. By clicking the link it contains, you will be definitively unsubscribed from list %1[% END %]
+ [%~ ELSIF notice.action == 'subscribe' ~%] +[%|loc(list)%]You requested a subscription to list %1[%END%]
+[%|loc%]To confirm your identity and prevent anyone from subscribing you to this list against your will, a message containing an validation link was sent to the e-mail address you provided.[%END%]
+[%|loc(list)%]Check your mailbox for new messages and click this link. This will confirm your subscription to list %1.[%END%]
+ [%~ ELSIF notice.action == 'signoff' ~%] +[%|loc(list)%]We need to check your identity before validating your unsubscription request for list %1. If you have a user account you should login or create an account.
Otherwise we can send you an email with a validation link inside; please provide your email address below to receive this validation link.[%END%]
[%|loc%]We've sent you an email including a validation link. You should check your mailbox to read this email and use this validation link.[%END%]
+ [%~ END %] [% ELSIF notice.msg == 'add_performed' %][%|loc(list,email)%]You are not subscribed to list %1 with e-mail address %2[%END%]
+[%|loc%]You might have subscribed with another address. Please contact the list owner to help you unsubscribe:[%END%]
+++ +[%~ ELSE ~%] +[% '' | mailto("${list}-request@${conf.host}") %]
+
[%|loc(list)%]You asked to be unsubscribed from list %1[%END%]
+[%|loc%]To confirm your request, please click the button below:[%END%]
+ + +[% END %] + diff --git a/default/web_tt2/sigrequest.tt2 b/default/web_tt2/sigrequest.tt2 deleted file mode 100644 index ea34a417c..000000000 --- a/default/web_tt2/sigrequest.tt2 +++ /dev/null @@ -1,43 +0,0 @@ - - - [% IF status == 'user.email' %] - [%|loc(list)%]You asked to be unsubscribed from list %1[%END%].+ [%|loc(list)%]You are already subscribed to list %1[%END%]. +
+ +[%~ ELSE ~%] + [% IF listconf.custom_attribute.size() ~%] +[%|loc(list)%]You want to subscribe to list %1[%END%]. + [%|loc%]Please fill in the form below and then click the validation button:[%END%]
+ [%~ ELSE ~%] +[%|loc(list)%]You requested a subscription to list %1[%END%]. + [%|loc%]To confirm your request, please click the button below:[%END%]
+ [%~ END %] + + +[%~ END %] + diff --git a/po/sympa/POTFILES.in b/po/sympa/POTFILES.in index 58e71964c..450f303ab 100644 --- a/po/sympa/POTFILES.in +++ b/po/sympa/POTFILES.in @@ -255,13 +255,13 @@ default/web_tt2/setlang.tt2 default/web_tt2/set_pending_list_request.tt2 default/web_tt2/show_cert.tt2 default/web_tt2/show_sessions.tt2 -default/web_tt2/sigrequest.tt2 +#default/web_tt2/sigrequest.tt2 default/web_tt2/skinsedit.tt2 default/web_tt2/sso_login.tt2 default/web_tt2/stats.tt2 default/web_tt2/subindex.tt2 default/web_tt2/suboptions.tt2 -default/web_tt2/subrequest.tt2 +#default/web_tt2/subrequest.tt2 default/web_tt2/ticket.tt2 default/web_tt2/title.tt2 default/web_tt2/tt2_error.tt2 diff --git a/src/cgi/wwsympa.fcgi.in b/src/cgi/wwsympa.fcgi.in index bfadb886b..592e9219c 100644 --- a/src/cgi/wwsympa.fcgi.in +++ b/src/cgi/wwsympa.fcgi.in @@ -79,6 +79,7 @@ use Sympa::Robot; use Sympa::Scenario; use Sympa::Session; use Sympa::SharedDocument; +use Sympa::Spindle::ProcessRequest; use Sympa::Spindle::ResendArchive; use Sympa::Spool::Archive; use Sympa::Spool::Auth; @@ -167,16 +168,16 @@ our %comm = ( 'sso_login' => 'do_sso_login', 'sso_login_succeeded' => 'do_sso_login_succeeded', 'subscribe' => 'do_subscribe', - 'multiple_subscribe' => 'do_multiple_subscribe', - 'subrequest' => 'do_subrequest', + #'multiple_subscribe' => 'do_multiple_subscribe', + #'subrequest' => 'do_subrequest', 'subindex' => 'do_subindex', 'suboptions' => 'do_suboptions', 'signoff' => 'do_signoff', 'auto_signoff' => 'do_auto_signoff', 'family_signoff' => 'do_family_signoff', 'family_signoff_request' => 'do_family_signoff_request', - #XXX'multiple_signoff' => 'do_multiple_signoff', - 'sigrequest' => 'do_sigrequest', + #XXX'multiple_signoff' => 'do_multiple_signoff', + #'sigrequest' => 'do_sigrequest', 'sigindex' => 'do_sigindex', 'ignoresub' => 'do_ignoresub', 'ignoresig' => 'do_ignoresig', @@ -338,6 +339,12 @@ our %comm = ( 'automatic_lists_management' => 'do_automatic_lists_management', 'automatic_lists_request' => 'do_automatic_lists_request', 'automatic_lists' => 'do_automatic_lists', + 'auth' => 'do_auth', +); + +my %comm_aliases = ( + 'sigrequest' => 'signoff', + 'subrequest' => 'subscribe', ); my %auth_action = ( @@ -411,16 +418,15 @@ our %action_args = ( 'home' => [], 'help' => ['help_topic'], 'show_cert' => [], - 'subscribe' => ['list', 'email', 'passwd'], + 'subscribe' => ['list'], #'subrequest' => ['list','email'], - 'subrequest' => ['list'], 'subindex' => ['list'], 'ignoresub' => ['list', '@email', '@gecos'], - 'signoff' => ['list', 'email', 'passwd'], - 'auto_signoff' => ['list', 'email'], + 'signoff' => ['list'], + 'auto_signoff' => ['list'], 'family_signoff' => ['family', 'email'], 'family_signoff_request' => ['family', 'email'], - 'sigrequest' => ['list', 'email'], + #'sigrequest' => ['list', 'email'], 'sigindex' => ['list'], 'ignoresig' => ['list', '@email'], 'set' => ['list', 'email', 'reception', 'gecos'], @@ -469,8 +475,6 @@ our %action_args = ( 'rss_request' => ['list'], 'request_topic' => ['list', 'authkey'], 'tag_topic_by_sender' => ['list'], - 'multiple_subscribe' => ['lists'], - 'multiple_signoff' => ['lists'], 'ticket' => ['ticket'], 'change_email' => ['email'], 'manage_template' => ['subaction', 'list', 'message_template'], @@ -487,6 +491,7 @@ our %action_args = ( 'automatic_lists_management' => [], 'automatic_lists_request' => ['family'], 'automatic_lists' => [], + 'auth' => ['id', 'heldaction', 'listname'], ); ## Define the required parameters for each action @@ -511,6 +516,8 @@ our %required_args = ( 'arcsearch' => ['param.list'], 'arcsearch_form' => ['param.list'], 'arcsearch_id' => ['param.list'], + 'auth' => ['id', 'heldaction', 'email'], + 'auto_signoff' => ['param.list', 'email'], 'automatic_lists_request' => ['family'], 'automatic_lists' => ['family'], 'attach' => ['param.list'], @@ -578,7 +585,6 @@ our %required_args = ( ['param.list', 'param.user.email', 'message_template', 'content'], 'modindex' => ['param.list', 'param.user.email'], 'docindex' => ['param.list', 'param.user.email'], - 'multiple_subscribe' => ['param.list'], 'pref' => ['param.user.email'], 'purge_list' => ['param.user.email', 'selected_lists'], 'rebuildallarc' => ['param.user.email'], @@ -616,13 +622,11 @@ our %required_args = ( 'setpref' => ['param.user.email'], 'sigindex' => ['param.list', 'param.user.email'], 'signoff' => ['param.list'], - 'sigrequest' => ['param.list'], 'skinsedit' => ['param.user.email'], 'sso_login' => ['auth_service_name'], 'stats' => ['param.list'], 'subindex' => ['param.list', 'param.user.email'], 'suboptions' => ['param.list', 'param.user.email'], - 'subrequest' => ['param.list'], 'subscribe' => ['param.list'], 'subscriber_count' => ['param.list'], 'suspend' => ['param.list', 'param.user.email'], @@ -1573,6 +1577,9 @@ while ($query = new_loop()) { ## Action my $action = $in{'action'}; + # Resolve alias. + $action = $comm_aliases{$action} + while $action and exists $comm_aliases{$action}; # Store current action in the session in order to redirect after a login # or other temporary actions. @@ -5592,326 +5599,104 @@ sub do_viewfile { return 1; } -#################################################### -# do_subscribe -#################################################### # Subscribes a user to the list -# -# IN : - -# -# OUT :'subrequest'|'login'|'info'|$in{'previous_action'} -# | undef -#################################################### -## TOTO: accepter nouveaux users +# IN : email, gecos, custom_attribute. +# OUT :'subscribe' | 'info' | $in{'previous_action'} | undef sub do_subscribe { wwslog('info', '(%s)', $in{'email'}); return undef if purely_closed('subscribe'); #FIXME: mv this to Scenario - if ($param->{'user'} and $param->{'user'}{'email'}) { - if ($list->{'admin'}{'custom_attribute'}) { - # This variable is set in the subrequest form. - # If not set, it means that the user has not been prompted to - # provide custom_attributes. - unless ($in{'via_subrequest'}) { - wwslog('notice', 'Returning subrequest form'); - return "subrequest"; - } - unless ( - _check_custom_attribute( - $list, $param->{action}, $in{custom_attribute} - ) - ) { - wwslog('notice', "Missing required custom attributes"); - return 'subrequest'; - } - } - - unless ($in{'via_subrequest'}) { - # Action confirmed? - my $next_action = $session->confirm_action( - $in{'action'}, $in{'response_action'}, - arg => $param->{'user'}{'email'}, - previous_action => ($in{'previous_action'} || 'info') - ); - return $next_action unless $next_action eq '1'; - } - - if ($param->{'is_subscriber'}) { - Sympa::Report::reject_report_web('user', 'already_subscriber', - {'list' => $list->{'name'}}, - $param->{'action'}, $list); - wwslog('info', '%s already subscriber', - $param->{'user'}{'email'}); - web_db_log( - { 'parameters' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'already_subscriber' - } - ); - return undef; - } - my $result = Sympa::Scenario::request_action( - $list, - 'subscribe', - $param->{'auth_method'}, - { 'sender' => $param->{'user'}{'email'}, - 'remote_host' => $param->{'remote_host'}, - 'remote_addr' => $param->{'remote_addr'} - } - ); - my $sub_is; - my $reason; - if (ref($result) eq 'HASH') { - $sub_is = $result->{'action'}; - $reason = $result->{'reason'}; - } - if ($sub_is =~ /reject/) { - Sympa::Report::reject_report_web('auth', $reason, {}, - $param->{'action'}, $list); - wwslog('info', 'Subscribe closed'); - web_db_log( - { 'parameters' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'authorization' - } - ); - return undef; - } - $param->{'may_subscribe'} = 1; - - if ($sub_is =~ /owner/) { - my $spool_req = Sympa::Spool::Auth->new; - my $request = Sympa::Request->new( - context => $list, - action => 'add', - custom_attribute => $in{custom_attribute}, - email => $param->{'user'}{'email'}, - gecos => $param->{'user'}{'gecos'}, - sender => $param->{'user'}{'email'}, - ); - my $keyauth = $spool_req->store($request); - - $list->send_notify_to_owner( - 'subrequest', - { 'who' => $param->{'user'}{'email'}, - 'keyauth' => $keyauth, - 'replyto' => Sympa::get_address($list, 'sympa'), - 'custom_attribute' => $in{custom_attribute}, - 'gecos' => $param->{'user'}{'gecos'}, - 'ip' => $ip - } - ); + if ( $param->{'user'}{'email'} + and $list->is_list_member($param->{'user'}{'email'})) { + # Already subscribed and logged in. + return 1; + } - Sympa::Report::notice_report_web('sent_to_owner', {}, - $param->{'action'}); - wwslog('info', 'Subscribe sent to owners'); + my ($email, $gecos); + if ($param->{'user'} and $param->{'user'}{'email'}) { + $email = $param->{'user'}{'email'}; + $gecos = $in{'gecos'} || $param->{'user'}{'gecos'}; + } else { + # User is not autenticated. + $email = Sympa::Tools::Text::canonic_email($in{'email'}); + $gecos = $in{'gecos'}; + } - return 'info'; - } elsif ($sub_is =~ /do_it/) { - if ($param->{'is_subscriber'}) { - unless ( - $list->update_list_member( - $param->{'user'}{'email'}, - subscribed => 1, - update_date => time - ) - ) { - Sympa::Report::reject_report_web( - 'intern', - 'update_subscriber_db_failed', - {'sub' => $param->{'user'}{'email'}}, - $param->{'action'}, - $list, - $param->{'user'}{'email'}, - $robot - ); - wwslog('info', 'Update failed'); - web_db_log( - { 'parameters' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'internal' - } - ); - return undef; - } - } else { - # If a list is not 'open' and allow_subscribe_if_pending - # has been set to 'off', returns undef. - unless ( - $list->{'admin'}{'status'} eq 'open' - or Conf::get_robot_conf( - $robot, 'allow_subscribe_if_pending' - ) eq 'on' - ) { - Sympa::Report::reject_report_web('user', 'list_not_open', - {'status' => $list->{'admin'}{'status'}}, - $param->{'action'}); - wwslog('info', 'List not open'); - web_db_log( - { 'target_email' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'list_not_open' - } - ); - return undef; - } + @{$param}{qw(email gecos custom_attribute)} = + ($email, $gecos, $in{'custom_attribute'}); - my $defaults = $list->get_default_user_options(); - my $u; - %{$u} = %{$defaults}; - $u->{'email'} = $param->{'user'}{'email'}; - $u->{'gecos'} = $param->{'user'}{'gecos'} || $in{'gecos'}; - $u->{'date'} = $u->{'update_date'} = time; - $u->{'password'} = $param->{'user'}{'password'}; - if (my $reason = Sympa::Tools::Password::password_validation( - $u->{'password'} - ) - ) { - Sympa::Report::reject_report_web('user', - 'passwd_validation', {'reason' => $reason}, - $param->{'action'}); - wwslog('info', 'Password validation'); - web_db_log( - { 'status' => 'error', - 'error_type' => 'bad_parameter' - } - ); - return undef; - } - $u->{custom_attribute} = $in{custom_attribute} - if $in{custom_attribute}; - $u->{'lang'} = $param->{'user'}{'lang'} || $param->{'lang'}; - $u->{'parameter'} = 'manual subscription'; - - $list->add_list_member($u); - if (defined $list->{'add_outcome'}{'errors'}) { - if (defined $list->{'add_outcome'}{'errors'} - {'max_list_members_exceeded'}) { - Sympa::Report::reject_report_web( - 'user', - 'max_list_members_exceeded', - { max_list_members => - $list->{'admin'}{'max_list_members'}, - list => $list->{'name'}, - 'sub' => $param->{'user'}{'email'} - }, - $param->{'action'}, - $list, - $param->{'user'}{'email'}, - $robot - ); - } else { - my $error = $language->gettext_sprintf( - 'Unable to add user %s in list %s : %s', - $u->{'email'}, - $list->{'name'}, - $list->{'add_outcome'}{'errors'}{'error_message'} - ); - Sympa::Report::reject_report_web( - 'intern', - $error, - {'sub' => $param->{'user'}{'email'}}, - $param->{'action'}, - $list, - $param->{'user'}{'email'}, - $robot - ); - } - wwslog( - 'info', - 'Subscribe failed: %s', - $list->{'add_outcome'}{'errors'}{'error_message'} - ); - web_db_log( - { 'parameters' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'internal' - } - ); - return "info"; - } - } - - unless ($sub_is =~ /quiet/i) { - unless ( - $list->send_probe_to_user( - 'welcome', $param->{'user'}{'email'} - ) - ) { - wwslog( - 'notice', - 'Unable to send "welcome" probe to %s', - $param->{'user'}{'email'} - ); - } - } + if ($list->{'admin'}{'custom_attribute'} + and not _check_custom_attribute( + $list, $param->{'action'}, $in{'custom_attribute'} + ) + ) { + wwslog('notice', "Missing required custom attributes"); + return 1; + } + unless ($email and Sympa::Tools::Text::valid_email($email)) { + return 1; + } - if ($sub_is =~ /notify/) { - $list->send_notify_to_owner( - 'notice', - { 'who' => $param->{'user'}{'email'}, - 'gecos' => $param->{'user'}{'gecos'}, - 'command' => 'subscribe' - } - ); - } + # Action confirmed? + my $next_action = $session->confirm_action( + $in{'action'}, $in{'response_action'}, + arg => join(',', grep {$_} ($email, $gecos)), + previous_action => ($in{'previous_action'} || 'info') + ); + return $next_action unless $next_action eq '1'; - } - } else { # user is not autenticated + my $spindle = Sympa::Spindle::ProcessRequest->new( + context => $list, + action => 'subscribe', + sender => $email, + email => $email, + gecos => $gecos, + ( $in{'custom_attribute'} + ? (custom_attribute => $in{'custom_attribute'}) + : () + ), + ( $param->{'user'}{'email'} + ? (md5_check => 1) + : () + ), + scenario_context => { + sender => $email, + remote_host => $param->{'remote_host'}, + remote_addr => $param->{'remote_addr'}, + }, + ); + unless ($spindle and $spindle->spin) { + wwslog('err', 'Failed to add user'); + return undef; + } - if ($in{'email'} && $in{'passwd'}) { - $in{'previous_action'} = 'subscribe'; - $in{'previous_list'} = $param->{'list'}; - return 'login'; + foreach my $report (@{$spindle->{stash} || []}) { + if ($report->[1] eq 'notice') { + Sympa::Report::notice_report_web(@{$report}[2, 3], + $param->{'action'}); + } elsif ($report->[1] eq 'user' + and $report->[2] eq 'already_subscriber') { + # To prevent sniffing users, fake "You requested a subscription" + # notice. + Sympa::Report::notice_report_web('sent_to_user', {}, + $param->{'action'}); } else { - return 'subrequest'; + Sympa::Report::reject_report_web(@{$report}[1 .. 3], + $param->{action}); } } - - Sympa::Report::notice_report_web('performed', {}, $param->{'action'}); - web_db_log({'parameters' => $in{'email'}, 'status' => 'success'}); - - if ($in{'previous_action'}) { - return $in{'previous_action'}; + unless (@{$spindle->{stash} || []}) { + Sympa::Report::notice_report_web('performed', {}, $param->{'action'}); + web_db_log({'parameters' => $in{'email'}, 'status' => 'success'}); } -# return 'suboptions'; - return 'info'; + return ($in{'previous_action'} || 'info'); } -#################################################### -# do_multiple_subscribe -#################################################### -# Subscribes a user to each lists -# -# IN : lists a array of lists -# -# OUT :'subrequest'|'login'|'info'|$in{'previous_action'} -# | undef -#################################################### -sub do_multiple_subscribe { - wwslog('info', '(%s)', $in{'email'}); - - ## Not authenticated - unless (defined $param->{'user'} && $param->{'user'}{'email'}) { - ## no email - unless ($in{'email'}) { - return 'lists'; - } - } - - my @lists = split /\0/, $in{'lists'}; - my $total; - my %results; - - foreach my $requested_list (@lists) { - my $param->{'list'} = Sympa::List->new($requested_list, $robot); - $results{'requested_list'} = do_subscribe(); - } -} +# No longer used. +#sub do_multiple_subscribe; -## Subscription request (user not authenticated) sub do_suboptions { wwslog('info', ''); @@ -5991,130 +5776,69 @@ sub do_suboptions { return 1; } -## Subscription request (user not authenticated) -sub do_subrequest { - wwslog('info', '(%s, %s)', $in{'email'}, $in{custom_attribute}); - - return undef if (purely_closed('subscribe')); - $param->{'custom_attribute'} = $in{custom_attribute} - if $in{custom_attribute}; - - # Auth ? - if ($param->{'user'}{'email'}) { - # Subscriber ? - if ($param->{'is_subscriber'}) { - $param->{'status'} = 'auth_subscribed'; - } else { - $param->{'status'} = 'auth'; - } - return 1; - } - # Provided email parameter ? - unless ($in{'email'}) { - $param->{'status'} = 'notauth_noemail'; - return 1; - } - # Valid email address? - unless (Sympa::Tools::Text::valid_email($in{'email'})) { - Sympa::Report::reject_report_web('user', 'incorrect_email', - {'email' => $in{'email'}}, - $param->{'action'}, $list); - wwslog('info', 'Incorrect email %s', $in{'email'}); - web_db_log( - { 'target_email' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'incorrect_email' - } - ); - $param->{'status'} = 'notauth_noemail'; - return 1; - } - - # Subscriber ? - if ($list->is_list_member($in{'email'})) { - # To prevent sniffing users, fake "You requested a subscription" - # notice. - $param->{'login_error'} = 'ticket_sent'; - $param->{'status'} = 'notauth_passwordsent'; - return 1; - } - - $param->{'login_error'} = 'ticket_sent'; - $param->{'request_from_host'} = $ip; - $param->{'newuser'} = Sympa::User::get_global_user($in{'email'}) - if Sympa::User::is_global_user($in{'email'}); - unless ($param->{'newuser'}) { - $param->{'newuser'} = - {'email' => Sympa::Tools::Text::canonic_email($in{'email'})}; - } - # Need to send a password by email - $param->{'one_time_ticket'} = Sympa::Ticket::create( - $in{'email'}, $robot, - 'subscribe/' . $list->{'name'}, - $param->{'request_from_host'} - ); - unless (Sympa::send_file($robot, 'sendpasswd', $in{'email'}, $param)) { - wwslog('notice', 'Unable to send template "sendpasswd" to %s', - $in{'email'}); - $param->{'login_error'} = 'unable_to_send_ticket'; - } - # do_requestpasswd(); - $param->{'status'} = 'notauth_passwordsent'; - - return 1; -} +#OBSOLETED. Now 'subrequest' is an alias of 'subscribe'. +#sub do_subrequest; +# Unsubcribes a user from a list, without authentication. +# This function will be used for unsubscription link in such as the message +# footer. sub do_auto_signoff { - wwslog('info', ''); - ## If the URL isn't valid, then go to home page. No need to guide the - ## user: this function is supposed to be used by clicking on autocreated - ## URL only. - return Conf::get_robot_conf($robot, 'default_home') unless $in{'email'}; - - ## If unsubscribe is forbidden, reject the request. Other + wwslog('info', '(%s)', $in{'email'}); + # If the URL isn't valid, then go to home page. No need to guide the + # user: this function is supposed to be used by clicking on autocreated + # URL only. + my $default_home = Conf::get_robot_conf($robot, 'default_home'); + return $default_home if purely_closed('unsubscribe'); #FIXME + my $email = Sympa::Tools::Text::canonic_email($in{'email'}); + return $default_home + unless $email and Sympa::Tools::Text::valid_email($email); - my $result = Sympa::Scenario::request_action( - $list, - 'unsubscribe', - $param->{'auth_method'}, - { 'sender' => $in{'email'}, - 'remote_host' => $param->{'remote_host'}, - 'remote_addr' => $param->{'remote_addr'} - } + # Action confirmed? + my $next_action = $session->confirm_action( + $in{'action'}, $in{'response_action'}, + arg => $email, + previous_action => $default_home ); - my $sig_is; - my $reason; - if (ref($result) eq 'HASH') { - $sig_is = $result->{'action'}; - $reason = $result->{'reason'}; - } + return $next_action unless $next_action eq '1'; - if ($sig_is =~ /reject/) { - Sympa::Report::reject_report_web('auth', $reason, {}, - $param->{'action'}, $list); - wwslog('info', '%s may not signoff from %s', - $in{'email'}, $param->{'list'}); - web_db_log( - { 'status' => 'error', - 'error_type' => 'authorization' - } - ); + my $spindle = Sympa::Spindle::ProcessRequest->new( + context => $list, + action => 'signoff', + sender => $email, + email => $email, + scenario_context => { + sender => $email, + remote_host => $param->{'remote_host'}, + remote_addr => $param->{'remote_addr'}, + }, + ); + unless ($spindle and $spindle->spin) { + wwslog('err', 'Failed to delete user'); return undef; } - ## Send the confirmation email to the user. - - if ($list->is_list_member($in{'email'})) { - Sympa::send_notify_to_user($list, 'ticket_to_signoff', $in{'email'}, - {context => 'auto_signoff', ip => $ip}) - or return undef; - } else { - return Conf::get_robot_conf($robot, 'default_home'); + foreach my $report (@{$spindle->{stash} || []}) { + if ($report->[1] eq 'notice') { + Sympa::Report::notice_report_web(@{$report}[2, 3], + $param->{'action'}); + } elsif ($report->[1] eq 'user' + and grep { $report->[2] eq $_ } + qw(user_not_subscriber not_subscriber)) { + # To prevent sniffing users, fake "We've sent validation link" + # notice. + Sympa::Report::notice_report_web('sent_to_user', {}, + $param->{'action'}); + } else { + Sympa::Report::reject_report_web(@{$report}[1 .. 3], + $param->{action}); + } + } + unless (@{$spindle->{stash} || []}) { + Sympa::Report::notice_report_web('performed', {}, $param->{'action'}); + web_db_log({'parameters' => $in{'email'}, 'status' => 'success'}); } - $param->{'signing_off_email'} = $in{'email'}; - # If OK, return the page displaying the information to the user. - return 1; + return $default_home; } sub do_family_signoff_request { @@ -6162,52 +5886,34 @@ sub do_family_signoff { } return 1; } -#################################################### -# do_signoff -#################################################### + # Unsubcribes a user from a list -# -# IN : - -# -# OUT : 'sigrequest' | 'login' | 'info' -# -#################################################### -## Unsubscribe from list +# IN : email +# OUT : 'signoff' | 'info' | undef sub do_signoff { - wwslog('info', ''); + wwslog('info', '(%s)', $in{'email'}); - return undef if (purely_closed('unsubscribe')); + return undef if purely_closed('unsubscribe'); #FIXME: mv this to Scenario - my $email = $param->{'user'}{'email'} || $in{'email'}; - unless ($email) { - return 'sigrequest'; - } elsif (not $param->{'user'}{'email'} and $in{'passwd'}) { #FIXME - # Perform login first. - $in{'previous_action'} = 'signoff'; - $in{'previous_list'} = $param->{'list'}; - return 'login'; + if ( $param->{'user'}{'email'} + and not $list->is_list_member($param->{'user'}{'email'})) { + # Not yet subscribed and already logged in. + return 1; } - # The check below will no longer be performed: Don't check if the user is - # registered so that an attempt to sniff users in user_table will fail. - #if (not $param->{'user'}{'email'} - # and Sympa::User::is_global_user($email)) { - # Sympa::Report::reject_report_web('user', 'no_user', {}, - # $param->{'action'}); - # wwslog('info', 'Need auth for user %s', $email); - # web_db_log( - # { 'target_email' => $email, - # 'status' => 'error', - # 'error_type' => 'authentication' - # } - # ); - # return undef; - #} - #XXX# No passwd - #XXXSympa::Tools::WWW::init_passwd($robot, $email, - #XXX {'lang' => $param->{'lang'}}); + my $email; + if ($param->{'user'} and $param->{'user'}{'email'}) { + $email = $param->{'user'}{'email'}; + } else { + # User is not autenticated. + $email = Sympa::Tools::Text::canonic_email($in{'email'}); + } - $param->{'email'} = $email; + $param->{email} = $email; + + unless ($email and Sympa::Tools::Text::valid_email($email)) { + return 1; + } # Action confirmed? my $next_action = $session->confirm_action( @@ -6217,201 +5923,55 @@ sub do_signoff { ); return $next_action unless $next_action eq '1'; - my %result = unsubscribe($email, $list); - if ($result{'success'} == 1) { - Sympa::Report::notice_report_web($result{'details'}, {}, - $param->{'action'}); - $param->{'is_subscriber'} = 0; - $param->{'may_signoff'} = 0; - } else { - Sympa::Report::reject_report_web( - $result{'category_error'}, - $result{'reason_error'}, - {%{$result{'details_error'} || {}}, 'list' => $list->{'name'}}, - $param->{'action'}, - $list - ); - } - return Conf::get_robot_conf($robot, 'default_home'); -} - -## Unsubscribe current user from a list. -sub unsubscribe { - my $email = shift; - my $list = shift; - - my %report = (success => 1, details => ''); - - unless ($list->is_list_member($email)) { - wwslog('info', '%s not subscribed to %s', $email, $list); - web_db_log( - { 'status' => 'error', - 'error_type' => 'not_subscriber' - } - ); - $report{'success'} = 0; - $report{'category_error'} = 'user'; - $report{'reason_error'} = 'not_subscribed'; - $report{'details_error'} = {}; - return %report; - } - - my $result = Sympa::Scenario::request_action( - $list, - 'unsubscribe', - $param->{'auth_method'}, - { 'sender' => $param->{'user'}{'email'}, - 'remote_host' => $param->{'remote_host'}, - 'remote_addr' => $param->{'remote_addr'} - } + my $spindle = Sympa::Spindle::ProcessRequest->new( + context => $list, + action => 'signoff', + sender => $email, + email => $email, + ( $param->{'user'}{'email'} + ? (md5_check => 1) + : () + ), + scenario_context => { + sender => $email, + remote_host => $param->{'remote_host'}, + remote_addr => $param->{'remote_addr'}, + }, ); - my $sig_is; - my $reason; - if (ref($result) eq 'HASH') { - $sig_is = $result->{'action'}; - $reason = $result->{'reason'}; + unless ($spindle and $spindle->spin) { + wwslog('err', 'Failed to delete user'); + return undef; } - $param->{'may_signoff'} = 1 if ($sig_is =~ /do_it|owner/); - - if ($sig_is =~ /reject/) { - wwslog('info', '%s may not signoff from %s', $email, $list); - web_db_log( - { 'status' => 'error', - 'error_type' => 'authorization' - } - ); - $report{'success'} = 0; - $report{'category_error'} = 'auth'; - $report{'reason_error'} = $reason; - $report{'details_error'} = {}; - return %report; - } elsif ($sig_is =~ /owner/) { - my $spool_req = Sympa::Spool::Auth->new; - my $request = Sympa::Request->new( - context => $list, - action => 'del', - email => $email, - sender => $param->{'user'}{'email'}, - ); - my $keyauth = $spool_req->store($request); - - $list->send_notify_to_owner( - 'sigrequest', - { 'who' => $param->{'user'}{'email'}, - 'keyauth' => $keyauth, - } - ); - - wwslog('info', 'Signoff sent to owner'); - $report{'success'} = 1; - $report{'details'} = 'sent_to_owner'; - return %report; - } else { - # If a list is not 'open' and allow_subscribe_if_pending has been set - # to 'off' returns error report. - unless ($list->{'admin'}{'status'} eq 'open' - or Conf::get_robot_conf($robot, 'allow_subscribe_if_pending') eq - 'on') { - wwslog('info', 'List not open'); - web_db_log( - { 'target_email' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'list_not_open' - } - ); - $report{'success'} = 0; - $report{'category_error'} = 'user'; - $report{'reason_error'} = 'list_not_open', - $report{'details_error'} = - {'status' => $list->{'admin'}{'status'}}; - return %report; - } - - unless ( - $list->delete_list_member( - 'users' => [$email], - 'exclude' => ' 1', - 'operation' => 'signoff', - ) - ) { - wwslog('info', 'Signoff failed'); - web_db_log( - { 'status' => 'error', - 'error_type' => 'internal' - } - ); - $report{'success'} = 0; - $report{'category_error'} = 'intern'; - $report{'reason_error'} = 'delete_subscriber_db_failed'; - $report{'details_error'} = {'sub' => $email}; - return %report; - } - - if ($sig_is =~ /notify/) { - $list->send_notify_to_owner( - 'notice', - { 'who' => $email, - 'gecos' => '', - 'command' => 'signoff' - } - ); - } - - unless (Sympa::send_file($list, 'bye', $email, {})) { - wwslog('notice', 'Unable to send template \'bye\' to %s', $email); + foreach my $report (@{$spindle->{stash} || []}) { + if ($report->[1] eq 'notice') { + Sympa::Report::notice_report_web(@{$report}[2, 3], + $param->{'action'}); + } elsif ($report->[1] eq 'user' + and grep { $report->[2] eq $_ } + qw(user_not_subscriber not_subscriber)) { + # To prevent sniffing users, fake "We've sent validation link" + # notice. + Sympa::Report::notice_report_web('sent_to_user', {}, + $param->{'action'}); + } else { + Sympa::Report::reject_report_web(@{$report}[1 .. 3], + $param->{action}); } } - web_db_log({'status' => 'success'}); - $report{'success'} = 1; - $report{'details'} = 'performed'; - return %report; -} - -## Unsubscription request (user not authenticated) -sub do_sigrequest { - wwslog('info', '(%s)', $in{'email'}); - - return undef if (purely_closed('unsubscribe')); - ## If user is authenticated then redirect him to the signoff action but - ## get a confirmation (via the sigrequest web page) first - if ($param->{'user'}{'email'}) { - return 1; - } - - ## Not auth & no email => return the sigrequest web form to get the user - ## email - unless ($in{'email'}) { - return 1; - } - ## valid email address? - unless (Sympa::Tools::Text::valid_email($in{'email'})) { - Sympa::Report::reject_report_web('user', 'incorrect_email', - {'email' => $in{'email'}}, - $param->{'action'}, $list); - wwslog('info', 'Incorrect email %s', $in{'email'}); - web_db_log( - { 'target_email' => $in{'email'}, - 'status' => 'error', - 'error_type' => 'incorrect_email' - } - ); - return 1; + unless (@{$spindle->{stash} || []}) { + Sympa::Report::notice_report_web('performed', {}, $param->{'action'}); + web_db_log({'parameters' => $in{'email'}, 'status' => 'success'}); } - # To prevent sniffing subscribers using signoff link, we always respond - # "We've sent you an email including a validation link" to anonymous user, - # but the email will be sent only if the user was really a subscriber. - if ($list->is_list_member($in{'email'})) { - Sympa::send_notify_to_user($list, 'ticket_to_signoff', $in{'email'}, - {ip => $ip}) - or return undef; - } + return ($in{'previous_action'} || 'info'); +} - $param->{'email'} = $in{'email'}; +# No longer used. +#sub unsubscribe; - return 1; -} +#OBSOLETED: Now an alias of 'signoff'. +#sub do_sigrequest; ## Update of password sub do_setpasswd { @@ -15775,58 +15335,6 @@ sub do_suspend_request_action { } Sympa::Report::notice_report_web('performed', {}, "Resume the subscription for the list(s)"); - - } - ## Unsubscribe from the selected lists - elsif ($in{'sub_action'} eq 'signoff') { - - # lists selected - @lists = split /\0/, $in{'listname'}; - my $report = ""; - foreach my $line (@lists) { - - my $unsub_list = Sympa::List->new($line, $robot); - unless ($unsub_list) { - wwslog('info', 'List %s unknown', $unsub_list); - return undef; - } - - my %result = unsubscribe($param->{'user'}{'email'}, $unsub_list); - if ($result{'success'} == 1) { - if ($result{'details'} eq 'sent_to_owner') { - $report .= $language->gettext_sprintf( - "Your unsubscription request to list %s was sent to the list owner.", - $unsub_list->{'name'} - ); - } else { - $report .= $language->gettext_sprintf( - "You were successfully unsubscribed from list %s.", - $unsub_list->{'name'}); - } - } else { - if ($result{'category_error'} eq 'auth') { - $report .= $language->gettext_sprintf( - "Unsubscription from list %s denied: Unsubscription from this list is closed.", - $unsub_list->{'name'} - ); - } else { - $report .= $language->gettext_sprintf( - "Unsubscription from list %s failed.", - $unsub_list->{'name'}); - } - } - $report .= "\n"; - - } - if ($lists[0] eq '') { - Sympa::Report::reject_report_web('user', 'missing_arg', - {'argument' => 'must picked one or more list(s)'}, - $param->{'action'}); - wwslog('info', 'Must picked one or more list(s)'); - return $previous_action; - } - - Sympa::Report::notice_report_web($report, {}, ''); } else { Sympa::Report::reject_report_web('user', 'unknown_action', {}, $in{'sub_action'}, $list); @@ -18398,6 +17906,62 @@ sub do_automatic_lists { return 'compose_mail'; } +sub do_auth { + wwslog('info', '(%s, %s, %s, %s)', + $in{'id'}, $in{'heldaction'}, $in{'listname'}, $in{'email'}); + + my $keyauth = $in{'id'}; + my $heldaction = $in{'heldaction'}; + my $listname = $in{'listname'}; + my $email = Sympa::Tools::Text::canonic_email($in{'email'}); + + my $default_home = Conf::get_robot_conf($robot, 'default_home'); + return $default_home + unless $email and Sympa::Tools::Text::valid_email($email); + + @{$param}{qw(id heldaction listname email)} = + ($keyauth, $heldaction, $listname, $email); + + # Action confirmed? + my $next_action = $session->confirm_action( + $in{'action'}, $in{'response_action'}, + arg => + join(',', grep {$_} ($keyauth, $heldaction, $listname, $email)), + previous_action => $default_home + ); + return $next_action unless $next_action eq '1'; + + my $spindle = Sympa::Spindle::ProcessRequest->new( + context => $robot, + action => 'auth', + keyauth => $keyauth, + sender => $email, + scenario_context => { + sender => $email, + remote_host => $param->{'remote_host'}, + remote_addr => $param->{'remote_addr'} + }, + ); + unless ($spindle and $spindle->spin) { + return $default_home; + } + + foreach my $report (@{$spindle->{stash} || []}) { + if ($report->[1] eq 'notice') { + Sympa::Report::notice_report_web(@{$report}[2, 3], + $param->{'action'}); + } else { + Sympa::Report::reject_report_web(@{$report}[1 .. 3], + $param->{action}); + } + } + unless (@{$spindle->{stash} || []}) { + Sympa::Report::notice_report_web('performed', {}, $param->{'action'}); + } + + return $default_home; +} + sub prevent_visibility_bypass { wwslog('debug2', 'Starting'); if (defined $list and ref $list eq 'Sympa::List') { diff --git a/src/lib/Sympa.pm b/src/lib/Sympa.pm index 468e4d408..b4e4d5ce4 100644 --- a/src/lib/Sympa.pm +++ b/src/lib/Sympa.pm @@ -522,13 +522,7 @@ sub send_notify_to_user { $param->{'to'} = $user; $param->{'type'} = $operation; - if ($operation eq 'ticket_to_signoff') { - $param->{one_time_ticket} = - Sympa::Ticket::create($user, $robot_id, - 'signoff/' . $list->{'name'}, - $param->{ip}) - or return undef; - } elsif ($operation eq 'ticket_to_family_signoff') { + if ($operation eq 'ticket_to_family_signoff') { $param->{one_time_ticket} = Sympa::Ticket::create($user, $robot_id, 'family_signoff/' . $param->{family} . '/' . $user, diff --git a/src/lib/Sympa/List.pm b/src/lib/Sympa/List.pm index be8240e9f..b3df2b9f0 100644 --- a/src/lib/Sympa/List.pm +++ b/src/lib/Sympa/List.pm @@ -1694,40 +1694,13 @@ sub send_notify_to_owner { ); } } - } elsif ($operation eq 'subrequest') { + } elsif ($operation eq 'sigrequest' or $operation eq 'subrequest') { + # Sends notifications by each so that auth links with owners' + # addresses will be included. foreach my $owner (@rcpt) { - $param->{'one_time_ticket'} = Sympa::Ticket::create( - $owner, - $robot, - 'subindex/' - . Sympa::Tools::Text::encode_uri($self->{'name'}), - $param->{'ip'} - ); unless ( Sympa::send_file( - $self, 'listowner_notification', [$owner], $param - ) - ) { - $log->syslog( - 'notice', - 'Unable to send template "listowner_notification" to %s list owner %s', - $self, - $owner - ); - } - } - } elsif ($operation eq 'sigrequest') { - foreach my $owner (@rcpt) { - $param->{'one_time_ticket'} = Sympa::Ticket::create( - $owner, - $robot, - 'sigindex/' - . Sympa::Tools::Text::encode_uri($self->{'name'}), - $param->{'ip'} - ); - unless ( - Sympa::send_file( - $self, 'listowner_notification', [$owner], $param + $self, 'listowner_notification', $owner, $param ) ) { $log->syslog( diff --git a/src/lib/Sympa/Request/Handler/auth.pm b/src/lib/Sympa/Request/Handler/auth.pm index 0051ef420..78acdfb0f 100644 --- a/src/lib/Sympa/Request/Handler/auth.pm +++ b/src/lib/Sympa/Request/Handler/auth.pm @@ -45,11 +45,17 @@ sub _twist { my $key = $request->{keyauth}; my $sender = $request->{sender}; - my $req = $request->{request}; # Request to be authorized. + # Optional $request->{request} is given by Sympa::Request::Message to + # check if "cmd" argument of e-mail command matches with held request. + my $req = $request->{request}; my $spindle = Sympa::Spindle::ProcessAuth->new( - context => $req->{context}, - action => $req->{action}, - email => $req->{email}, + ( $req + ? ( context => $req->{context}, + action => $req->{action}, + email => $req->{email} + ) + : () + ), keyauth => $key, confirmed_by => $sender, @@ -81,7 +87,8 @@ Sympa::Request::Handler::auth - auth request handler =head1 DESCRIPTION -Fetchs the request matching with {request} attribute from held request spool, +Fetchs the request matching with {authkey} and optional {request} attributes +from held request spool, and if succeeded, processes it with C