Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate one time ticket (2) (#156) #854

Merged
merged 4 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions default/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ nobase_default_DATA = \
scenari/d_read.private \
scenari/d_read.private-https \
scenari/d_read.public \
scenari/family_signoff.auth \
scenari/family_signoff.closed \
scenari/global_remind.listmaster \
scenari/info.open \
scenari/info.private \
Expand Down Expand Up @@ -216,8 +218,6 @@ nobase_default_DATA = \
web_tt2/editsubscriber.tt2 \
web_tt2/edit_template.tt2 \
web_tt2/error.tt2 \
web_tt2/family_signoff.tt2 \
web_tt2/family_signoff_request.tt2 \
web_tt2/footer.tt2 \
web_tt2/get_closed_lists.tt2 \
web_tt2/get_inactive_lists.tt2 \
Expand Down
4 changes: 2 additions & 2 deletions default/mail_tt2/listmaster_notification.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Subject: [%"List \"%1@%2\" creation request from %3"|loc(list.name,domain,email)
[% 'info' | url_abs([list.name]) %]

[%|loc%]To activate/delete this mailing list:[%END%]
[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'get_pending_lists' | url_abs %]

[%- ELSIF type == 'list_created' -%]
[% PROCESS 'list_created.tt2' -%]
Expand All @@ -30,7 +30,7 @@ Subject: [%"List \"%1\" renaming"|loc(list.name)|qencode%]
[% END %]

[%|loc%]To activate/delete this mailing list:[%END%]
[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'get_pending_lists' | url_abs %]

[% ELSIF type == 'no_db' -%]
Subject: [%"No database"|loc|qencode%]
Expand Down
2 changes: 1 addition & 1 deletion default/mail_tt2/listowner_notification.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Subject: [%"FYI: %1 List \"%2\" from %3 %4"|loc(type,list.name,who,gecos)|qencod
[%|loc(who,gecos,list.name)%]WARNING: %1 %2 failed to unsubscribe from %3 because their address was not found in the list.
You may help this person looking for similar email in subscriber list using the following link :[%END%]

[% 'ticket' | url_abs([one_time_ticket]) %]
[% 'search' | url_abs([list.name,who]) %]

[% ELSIF type == 'erase_customizing' -%]
Subject: [%"List \"%1\" customizations have been removed"|loc(list.name)|qencode%]
Expand Down
2 changes: 1 addition & 1 deletion default/mail_tt2/moderate.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Content-Disposition: inline

[% IF method == 'md5' -%]
[%|loc(mod_spool_size)%]%1 messages are awaiting moderation.[%END%]
[%|loc%]To view the messages, please click on the following URL:[%END%] <[% 'ticket' | url_abs([one_time_ticket]) %]>
[%|loc%]To view the messages, please click on the following URL:[%END%] <[% 'modindex' | url_abs([list.name]) %]>

[% IF request_topic -%][%|loc()%]This mailing list is configured to require topics; that's probably why this message went through the moderation process.[%END%]

Expand Down
9 changes: 7 additions & 2 deletions default/mail_tt2/request_auth.tt2
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
[%# request_auth.tt2 ~%]
To: [% to %]
[% IF conf.wwsympa_url && type == 'signoff' -%]
[% IF conf.wwsympa_url && type == 'family_signoff' -%]
Subject: [%"%1 / unsubscribing from family %2"|loc(conf.title,family.name)|qencode%]
[%- ELSIF conf.wwsympa_url && type == 'signoff' -%]
Subject: [%"%1 / unsubscribing from %2"|loc(conf.title,list.name)|qencode%]
[%- ELSIF conf.wwsympa_url && type == 'subscribe' -%]
Subject: [%"%1 / subscribing to %2"|loc(conf.title,list.name)|qencode%]
[%- ELSE -%]
Subject: [%"AUTH ${keyauth} ${cmd}"|qencode%]
[%- END %]

[% IF type == 'signoff' -%]
[% IF type == 'family_signoff' -%]
[%|loc(family.name)-%]You requested that your e-mail address be removed from family '%1'.[%- END -%]

[%- ELSIF type == 'signoff' -%]
[%|loc(list.name)-%]You requested that your e-mail address be removed from list '%1'.[%- END -%]

[%- ELSIF type == 'subscribe' -%]
Expand Down
11 changes: 0 additions & 11 deletions default/mail_tt2/user_notification.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ Subject: [%"Management of list %1"|loc(list.name)|qencode%]
[%|loc%]Owner and moderator guide:[%END%] [% 'help' | url_abs(['admin.html']) %]
[% END -%]

[% ELSIF type == 'ticket_to_family_signoff' -%]
Subject: [%"Unsubscribing from family %1"|loc(family)|qencode%]
[% IF context == 'family_signoff'%]
[%|loc(family,ip)%]Somebody (probably you) requested to unsubscribe you from family %1. This query was issued from the IP address %2.
To confirm and be removed from all the lists of this family, please click the link below: [%END%]
[% ELSE %]
[%|loc(family)%]You have requested to be removed from family %1. To confirm and be removed from all the lists of this family, please click the link below: [%END%]
[% END %]
[% 'ticket' | url_abs([one_time_ticket]) %]


[% ELSIF type == 'hundred_percent_error' -%]
Subject: [%"No valid recipient in list %1"|loc(list.name)|qencode%]

Expand Down
6 changes: 6 additions & 0 deletions default/scenari/family_signoff.auth
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# family_signoff.auth
title.gettext need authentication

!equal([sender],[email]) smtp,dkim,md5,smime -> request_auth([email])
true() smtp,dkim -> request_auth([email])
true() md5,smime -> do_it
4 changes: 4 additions & 0 deletions default/scenari/family_signoff.closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# family_signoff.closed
title.gettext impossible

true() smtp,dkim,md5,smime -> reject(reason='unsub_closed')
18 changes: 18 additions & 0 deletions default/web_tt2/confirm_action.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
[%|loc%]Add subscribers[%END%]
[%~ ELSIF heldaction == 'del' ~%]
[%|loc%]Delete selected email addresses[%END%]
[%~ ELSIF heldaction == 'family_signoff' ~%]
[%|loc%]Global unsubscription[%END%]
[%~ ELSIF heldaction == 'move_user' ~%]
[%|loc%]Changing user's email[%END%]
[%~ ELSIF heldaction == 'remind' || heldaction == 'global_remind' ~%]
Expand Down Expand Up @@ -217,6 +219,16 @@
[%|loc(shared_doc.name)%]Do you really want to delete %1?[%END%]
</strong>
</p>
[%~ ELSIF confirm_action == 'family_signoff' ~%]
<h2>
<i class="fa fa-check-circle"></i>
[%|loc%]Global unsubscription[%END%]
</h2>
<p>
<strong>
[%|loc(family)%]Do you really want to unsubscribe from the lists in family %1?[%END%]
</strong>
</p>
[%~ ELSIF confirm_action == 'move_list' ~%]
<h2>
<i class="fa fa-check-circle"></i>
Expand Down Expand Up @@ -387,6 +399,9 @@
<input type="hidden" name="heldaction" value="[% heldaction %]" />
<input type="hidden" name="listname" value="[% listname %]" />
<input type="hidden" name="email" value="[% email %]" />
[% IF heldaction == 'family_signoff' ~%]
<input type="hidden" name="family" value="[% family %]" />
[%~ END %]
[%~ ELSIF confirm_action == 'auth_add' ~%]
[% FOREACH i = id ~%]
<input type="hidden" name="id" value="[% i %]" />
Expand Down Expand Up @@ -453,6 +468,8 @@
<input type="hidden" name="d_admin" value="[% d_admin %]" />
[%~ ELSIF confirm_action == 'd_delete' ~%]
<input type="hidden" name="path" value="[% shared_doc.paths.join("/") %]" />
[%~ ELSIF confirm_action == 'family_signoff' ~%]
<input type="hidden" name="email" value="[% email %]" />
[%~ ELSIF confirm_action == 'move_user' ~%]
<input type="hidden" name="current_email" value="[% current_email %]" />
<input type="hidden" name="email" value="[% email %]" />
Expand Down Expand Up @@ -507,6 +524,7 @@
# Confirmation common hidden fields
#%]
<input type="hidden" name="action" value="[% confirm_action %]" />
<input type="hidden" name="family" value="[% family %]" />
<input type="hidden" name="list" value="[% list %]" />
<input type="hidden" name="previous_action" value="[% previous_action %]" />

Expand Down
6 changes: 0 additions & 6 deletions default/web_tt2/family_signoff.tt2

This file was deleted.

9 changes: 0 additions & 9 deletions default/web_tt2/family_signoff_request.tt2

This file was deleted.

6 changes: 0 additions & 6 deletions default/web_tt2/family_signoff_request2.tt2

This file was deleted.

119 changes: 71 additions & 48 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file at
# the top-level directory of this distribution and at
# Copyright 2017, 2018, 2019, 2020 The Sympa Community. See the AUTHORS.md
# file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>.
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -158,12 +158,12 @@ our %comm = (
'subscribe' => 'do_subscribe',
#'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',
'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',
'sigindex' => 'do_sigindex',
Expand Down Expand Up @@ -339,6 +339,7 @@ my %comm_aliases = (
'change_email_request' => 'move_user',
'del_fromsig' => 'auth_del',
'dump' => 'export_member',
'family_signoff_request' => 'family_signoff',
'ignoresig' => 'decl_del',
'ignoresub' => 'decl_add',
'loginrequest' => 'login',
Expand Down Expand Up @@ -412,12 +413,12 @@ our %action_args = (
'show_cert' => [],
'subscribe' => ['list'],
#'subrequest' => ['list','email'],
'subindex' => ['list'],
'decl_add' => ['list'],
'signoff' => ['list'],
'auto_signoff' => ['list'],
'family_signoff' => ['family', 'email'],
'family_signoff_request' => ['family', 'email'],
'subindex' => ['list'],
'decl_add' => ['list'],
'signoff' => ['list'],
'auto_signoff' => ['list'],
'family_signoff' => ['family'],
#'family_signoff_request' => ['family', 'email'],
#'sigrequest' => ['list', 'email'],
'sigindex' => ['list'],
'decl_del' => ['list'],
Expand Down Expand Up @@ -556,6 +557,7 @@ our %required_args = (
'editfile' => ['param.user.email'],
'editsubscriber' => ['param.list', 'param.user.email', 'email'],
'export_member' => ['param.list'],
'family_signoff' => ['family', 'email'],
'get_closed_lists' => ['param.user.email'],
'get_inactive_lists' => ['param.user.email'],
'get_latest_lists' => ['param.user.email'],
Expand Down Expand Up @@ -2725,7 +2727,7 @@ sub check_param_in {
next unless $family;

my $result =
Sympa::Scenario->new($family->{'robot'},
Sympa::Scenario->new($family->{'domain'},
'automatic_list_creation')->authz(
$param->{'auth_method'},
{ 'sender' => $param->{'user'}{'email'},
Expand Down Expand Up @@ -5763,50 +5765,71 @@ sub do_auto_signoff {
return $default_home;
}

sub do_family_signoff_request {
wwslog('info', '');
# Became an alias of do_family_signoff().
#sub do_family_signoff_request {

sub do_family_signoff {
wwslog('info', '(%s, %s)', $in{'family'}, $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.
return Conf::get_robot_conf($robot, 'default_home') unless $in{'email'};
my $default_home = Conf::get_robot_conf($robot, 'default_home');

my $scenario = Sympa::Scenario->new($robot, 'family_signoff')
or return undef;
return $default_home if $scenario->is_purely_closed;

return $default_home unless $in{'email'} and $in{'family'}; #FIXME
my $family = Sympa::Family->new($in{'family'}, $robot);
return Conf::get_robot_conf($robot, 'default_home') unless $family;
return $default_home
unless $family;
my $email = Sympa::Tools::Text::canonic_email($in{'email'});
return $default_home
unless $email and Sympa::Tools::Text::valid_email($email);

Sympa::send_notify_to_user(
$robot,
'ticket_to_family_signoff',
$in{'email'},
{context => 'family_signoff', family => $family->{'name'}, ip => $ip}
) or return undef;

$param->{'signing_off_email'} = $in{'email'};
$param->{'family'} = $in{'family'};
# If OK, return the page displaying the information to the user.
return 1;
}
$param->{'email'} = $email;
$param->{'family'} = $family->{name};

sub do_family_signoff {
wwslog('info', '');
$param->{'signing_off_email'} = $in{'email'};
$param->{'family'} = $in{'family'};
# Action confirmed?
my $next_action = $session->confirm_action(
$in{'action'}, $in{'response_action'},
arg => $email,
previous_action => $default_home
);
return $next_action unless $next_action eq '1';

unless ($in{'email'} eq $session->{'email'}) {
Sympa::WWW::Report::reject_report_web('user', 'cannot_do_signoff');
wwslog('err',
'User %s tried to unsubscribe address %s from family %s',
$session->{'email'}, $in{'email'}, $in{'family'});
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $family,
action => 'family_signoff',
sender => 'nobody',
email => $email,
scenario_context => {
sender => 'nobody',
remote_host => $param->{'remote_host'},
remote_addr => $param->{'remote_addr'},
},
);
unless ($spindle and $spindle->spin) {
wwslog('err', 'Failed to delete user');
return undef;
}

my $family = Sympa::Family->new($param->{'family'}, $robot);
unless ($family
and $family->insert_delete_exclusion($in{'email'}, 'insert')) {
Sympa::WWW::Report::reject_report_web('user', 'cannot_do_signoff');
wwslog('err', 'Unsubscription of address %s from family %s failed',
$in{'email'}, $in{'family'});
return undef;
foreach my $report (@{$spindle->{stash} || []}) {
if ($report->[1] eq 'notice') {
Sympa::WWW::Report::notice_report_web(@{$report}[2, 3],
$param->{'action'});
} else {
Sympa::WWW::Report::reject_report_web(@{$report}[1 .. 3],
$param->{action});
}
}
return 1;
unless (@{$spindle->{stash} || []}) {
Sympa::WWW::Report::notice_report_web('performed_soon', {},
$param->{'action'});
web_db_log({'parameters' => $in{'email'}, 'status' => 'success'});
}

return $default_home;
}

# Unsubcribes a user from a list
Expand Down
1 change: 1 addition & 0 deletions src/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ nobase_modules_DATA = \
Sympa/Request/Handler/decl.pm \
Sympa/Request/Handler/del.pm \
Sympa/Request/Handler/distribute.pm \
Sympa/Request/Handler/family_signoff.pm \
Sympa/Request/Handler/finished.pm \
Sympa/Request/Handler/get.pm \
Sympa/Request/Handler/global_remind.pm \
Expand Down