Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged revisions 1546-1548,1550,1557 via svnmerge from svn://svn.mong…

…ueurs.net/act/trunk

........
  r1546 | eric | 2007-07-12 14:01:45 -0700 (Thu, 12 Jul 2007) | 4 lines

  Make twostep more generic:
   twostep form and email templates, getting the email,
   getting twostep form errors, are supplied by calling handler
........
  r1547 | eric | 2007-07-12 17:34:53 -0700 (Thu, 12 Jul 2007) | 1 line

  Act::Form ordered global validation
........
  r1548 | eric | 2007-07-13 14:09:48 -0700 (Fri, 13 Jul 2007) | 2 lines

  change password in two steps replaces reset password
........
  r1557 | eric | 2007-07-26 23:47:53 -0700 (Thu, 26 Jul 2007) | 1 line

  resetpassword error message fixup
........


git-svn-id: svn://svn.mongueurs.net/act/branches/stable@1559 67b57a05-4208-db11-a765-00306e02d86a
  • Loading branch information...
commit 3f55908295338805c5fc6109d2166069dc5380d7 1 parent 1b0f572
Éric Cholet authored
Showing with 266 additions and 218 deletions.
  1. +2 −1  bin/dbinit
  2. +0 −2  doc/templates.pod
  3. +1 −1  eg/conf/startup.pl
  4. +5 −1 lib/Act/Database.pm
  5. +1 −2  lib/Act/Dispatcher.pm
  6. +9 −0 lib/Act/Form.pm
  7. +79 −1 lib/Act/Handler/User/ChangePassword.pm
  8. +25 −4 lib/Act/Handler/User/Register.pm
  9. +0 −126 lib/Act/Handler/User/ResetPassword.pm
  10. +71 −46 lib/Act/TwoStep.pm
  11. +15 −6 po/en.po
  12. +13 −5 po/fr.po
  13. +22 −0 t/form.t
  14. +1 −1  templates/login
  15. +0 −7 templates/twostep/form
  16. +0 −5 templates/twostep/ok
  17. +0 −1  templates/user/reset_password_body
  18. +6 −0 templates/{core/twostep/form → user/twostep_add}
  19. 0  templates/{core/twostep/email_body → user/twostep_add_email_body}
  20. 0  templates/{core/twostep/email_subject → user/twostep_add_email_subject}
  21. +4 −0 templates/{core/twostep/ok → user/twostep_add_ok}
  22. +3 −9 templates/user/{resetpassword → twostep_change_password}
  23. +4 −0 templates/user/twostep_change_password_email_body
  24. 0  templates/user/{reset_password_subject → twostep_change_password_email_subject}
  25. +5 −0 templates/user/twostep_change_password_ok
View
3  bin/dbinit
@@ -247,6 +247,7 @@ CREATE TABLE twostep
(
token char(32) NOT NULL PRIMARY KEY,
email text NOT NULL,
- datetime timestamp without time zone
+ datetime timestamp without time zone,
+ data text,
);
EOF
View
2  doc/templates.pod
@@ -124,8 +124,6 @@ your own version of F<talk/schedule>.
=item * B<F<user/stats>>
-=item * B<F<user/resetpassword>>
-
=item * B<F<user/purchase>>
=item * B<F<user/change>>
View
2  eg/conf/startup.pl
@@ -28,11 +28,11 @@
use Act::Handler::Track::Edit;
use Act::Handler::Track::List;
use Act::Handler::User::Change;
+use Act::Handler::User::ChangePassword;
use Act::Handler::User::Main;
use Act::Handler::User::Photo;
use Act::Handler::User::Purchase;
use Act::Handler::User::Register;
-use Act::Handler::User::ResetPassword;
use Act::Handler::User::Rights;
use Act::Handler::User::Search;
use Act::Handler::User::Show;
View
6 lib/Act/Database.pm
@@ -13,7 +13,11 @@ my @SCHEMA_UPDATES = (
alter table orders add column type text;
",
#3
- "alter table users rename civility to salutation;"
+ "alter table users rename civility to salutation;
+ ",
+#4
+ "alter table twostep add column data text;
+ ",
);
# returns ( current database schema version, required version )
View
3  lib/Act/Dispatcher.pm
@@ -17,12 +17,12 @@ use constant DEFAULT_PAGE => 'index.html';
# main dispatch table
my %public_handlers = (
atom => 'Act::Handler::News::Atom',
+ changepwd => 'Act::Handler::User::ChangePassword',
event => 'Act::Handler::Event::Show',
events => 'Act::Handler::Event::List',
login => 'Act::Handler::Login',
news => 'Act::Handler::News::List',
register => 'Act::Handler::User::Register',
- resetpw => 'Act::Handler::User::ResetPassword',
schedule => 'Act::Handler::Talk::Schedule',
search => 'Act::Handler::User::Search',
stats => 'Act::Handler::User::Stats',
@@ -34,7 +34,6 @@ my %public_handlers = (
);
my %private_handlers = (
change => 'Act::Handler::User::Change',
- changepwd => 'Act::Handler::User::ChangePassword',
create => 'Act::Handler::User::Create',
csv => 'Act::Handler::CSV',
editevent => 'Act::Handler::Event::Edit',
View
9 lib/Act/Form.pm
@@ -64,6 +64,15 @@ sub validate
or $self->{invalid}{$field} = $type;
}
}
+ # global validation
+ if ($self->{profile}{global}) {
+ for my $g ( @{ $self->{profile}{global} } ) {
+ unless ($g->( $self->{fields} )) {
+ $self->{invalid}{global} = 1;
+ last;
+ }
+ }
+ }
# return true if validation successful
return 0 == keys %{$self->{invalid}};
}
View
80 lib/Act/Handler/User/ChangePassword.pm
@@ -1,7 +1,8 @@
package Act::Handler::User::ChangePassword;
use strict;
-
+
+use Act::Auth;
use Act::Config;
use Act::Form;
use Act::Template::HTML;
@@ -15,6 +16,44 @@ my $form = Act::Form->new(
newpassword2 => sub { lc shift },
},
);
+# twostep form
+my $twostep_form = Act::Form->new(
+ optional => [qw(login email)],
+ filters => {
+ login => sub { lc shift },
+ email => sub { lc shift },
+ },
+ constraints => {
+ email => 'email',
+ },
+ global => [ sub {
+ my $fields = shift;
+ # exactly one of the fields must be provided
+ my %key;
+ for my $f (qw(login email)) {
+ if ($fields->{$f}) {
+ if (%key) {
+ %key = ();
+ last;
+ }
+ %key = ($f => $fields->{$f});
+ }
+ }
+ unless (%key) {
+ $fields->{error} = 'ERR_LOGIN_OR_EMAIL';
+ return;
+ }
+ # search for user
+ $fields->{user} = Act::User->new(%key);
+ unless ($fields->{user}) {
+ $fields->{error} = 'ERR_USER_NOT_FOUND';
+ return;
+ }
+ return 1;
+ } ],
+);
+# twostep template
+my $twostep_template = 'user/twostep_change_password';
sub handler
{
@@ -24,6 +63,13 @@ sub handler
# form has been submitted
my @errors;
+ # must have a valid twostep token if not logged in
+ my ($token, $token_data);
+ unless ($Request{user}) {
+ ($token, $token_data) = Act::TwoStep::verify_form()
+ or return;
+ }
+
# validate form fields
my $ok = $form->validate($Request{args});
$fields = $form->{fields};
@@ -35,10 +81,19 @@ sub handler
}
if ($ok) {
+ # remove token and authenticate user if twostep
+ unless ($Request{user}) {
+ my $user = Act::User->new(user_id => $token_data)
+ or die "unknown user_id: $token_data\n";
+ my $sid = Act::Util::create_session($user);
+ Act::Auth->send_cookie($sid);
+ Act::TwoStep::remove($token);
+ }
# update user
$Request{user}->update(
passwd => Act::Util::crypt_password( $fields->{newpassword1} )
);
+
# redirect to user's main page
return Act::Util::redirect(make_uri('main'));
}
@@ -50,6 +105,29 @@ sub handler
}
$template->variables(errors => \@errors);
}
+ elsif ($Request{args}{twostepsubmit}) { # two-step form has been submitted
+ # validate form and create a new token
+ if (Act::TwoStep::create(
+ $twostep_template, $twostep_form,
+ 'user/twostep_change_password_email_subject', 'user/twostep_change_password_email_body',
+ sub { $twostep_form->{fields}{user}{email} },
+ sub { my @errors;
+ $twostep_form->{invalid}{global} && push @errors, $twostep_form->{fields}{error};
+ $twostep_form->{invalid}{email} eq 'email' && push @errors, 'ERR_EMAIL_SYNTAX';
+ return \@errors;
+ },
+ sub { $twostep_form->{fields}{user}{user_id} },
+ )) {
+ # twostep form is valid, display confirmation page
+ $template->process('user/twostep_change_password_ok');
+ }
+ return;
+ }
+ elsif (!$Request{user}) { # user not logged in
+ # do we have a twostep token in the uri?
+ Act::TwoStep::verify_uri($twostep_template)
+ or return;
+ }
# display form
$template->process('user/change_password');
}
View
29 lib/Act/Handler/User/Register.pm
@@ -13,6 +13,16 @@ use Apache::Constants qw(FORBIDDEN);
use DateTime;
use DateTime::Format::Pg;
+# twostep form
+my $twostep_form = Act::Form->new(
+ required => [qw(email)],
+ filters => { email => sub { lc shift } },
+ constraints => { email => 'email' },
+);
+
+# twostep template filename
+my $twostep_template = 'user/twostep_add';
+
# registration form
my $form = Act::Form->new(
required => [qw(login first_name last_name email country tshirt )],
@@ -70,12 +80,11 @@ sub handler
my $template = Act::Template::HTML->new();
my $fields = {};
my $duplicates = [];
- my $token;
if ($Request{args}{join}) { # registration form has been submitted
# must have a valid twostep token
- $token = Act::TwoStep::verify_form()
+ (my $token) = Act::TwoStep::verify_form()
or return;
my @errors;
@@ -152,12 +161,24 @@ sub handler
}
elsif ($Request{args}{twostepsubmit}) { # two-step form has been submitted
# validate form and create a new token
- Act::TwoStep::create();
+ if (Act::TwoStep::create(
+ $twostep_template, $twostep_form,
+ 'user/twostep_add_email_subject', 'user/twostep_add_email_body',
+ sub { $twostep_form->{fields}{email} },
+ sub { my @errors;
+ $twostep_form->{invalid}{email} eq 'required' && push @errors, 'ERR_EMAIL';
+ $twostep_form->{invalid}{email} eq 'email' && push @errors, 'ERR_EMAIL_SYNTAX';
+ return \@errors;
+ },
+ )) {
+ $template->variables(email => $twostep_form->{fields}{email});
+ $template->process('user/twostep_add_ok');
+ }
return;
}
else {
# do we have a twostep token in the uri?
- $token = Act::TwoStep::verify_uri()
+ Act::TwoStep::verify_uri($twostep_template)
or return;
}
# display the registration form
View
126 lib/Act/Handler/User/ResetPassword.pm
@@ -1,126 +0,0 @@
-package Act::Handler::User::ResetPassword;
-
-use strict;
-
-use Act::Config;
-use Act::Email;
-use Act::Form;
-use Act::Template::HTML;
-use Act::User;
-use Act::Util;
-
-# reset password form
-my $form = Act::Form->new(
- optional => [qw(login email)],
- filters => {
- login => sub { lc shift },
- email => sub { lc shift },
- },
- constraints => {
- email => 'email',
- }
-);
-
-sub handler
-{
- my $template = Act::Template::HTML->new();
- my $fields;
-
- if ($Request{args}{ok}) {
- # form has been submitted
- my @errors;
-
- # validate form fields
- my $ok = $form->validate($Request{args});
- $fields = $form->{fields};
-
- # exactly one of the fields must be provided
- my %key;
- if ($ok) {
- for my $f (qw(login email)) {
- if ($fields->{$f}) {
- if (%key) {
- $ok = 0;
- last;
- }
- else {
- %key = ($f => $fields->{$f});
- }
- }
- }
- unless ($ok && %key) {
- $ok = 0;
- push @errors, 'ERR_LOGIN_OR_EMAIL';
- }
- }
- if ($ok) {
-
- # look for user
- my $user = Act::User->new(%key);
-
- if ($user) {
- # reset password
- my ($clear_passwd, $crypt_passwd) = Act::Util::gen_password();
-
- # update user
- $user->update(passwd => $crypt_passwd);
-
- # mail new password to user
- _send_email($user, $clear_passwd);
-
- # thanks for playing
- $template->variables(reset => 1);
- }
- else {
- push @errors, 'ERR_USER_NOT_FOUND';
- }
- }
- else {
- $form->{invalid}{email} eq 'email' && push @errors, 'ERR_EMAIL_SYNTAX';
- }
- $template->variables(errors => \@errors);
- }
- else {
- $fields = {};
- }
- # display form
- $template->variables(
- %$fields
- );
- $template->process('user/resetpassword');
-}
-
-sub _send_email
-{
- my ($user, $clear_passwd) = @_;
-
- # generate subject and body from templates
- my $template = Act::Template->new;
- my %output;
- for my $slot (qw(subject body)) {
- $template->variables(
- user => $user,
- passwd => $clear_passwd,
- );
- $template->process("user/reset_password_$slot", \$output{$slot});
- }
- # send the notification email
- Act::Email::send(
- from => $Config->email_sender_address,
- to => $user->email,
- %output,
- );
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Act::Handler::User::ResetPassword - reset a user's password
-
-=head1 DESCRIPTION
-
-See F<DEVDOC> for a complete discussion on handlers.
-
-=cut
View
117 lib/Act/TwoStep.pm
@@ -6,21 +6,16 @@ use Digest::MD5;
use Act::Config;
use Act::Email;
-use Act::Form;
use Act::Template;
use Act::Template::HTML;
use Act::Util;
-my $form = Act::Form->new(
- required => [qw(email)],
- filters => { email => sub { lc shift } },
- constraints => { email => 'email' },
-);
-
-# returns token if present in pathinfo and exists in database
-# otherwise displays the form and returns undef
+# returns true if token is present in pathinfo and exists in database
+# otherwise displays the twostep form and returns undef
sub verify_uri
{
+ my $template_file = shift;
+
# do we have an authentication token in the uri?
my $token = $Request{path_info};
if ($token) {
@@ -31,44 +26,46 @@ sub verify_uri
return;
}
# valid auth token
- return $token;
+ return 1;
}
# no token: display email address form
- _display_form();
+ _display_form($template_file);
return;
}
-# validate form and create a new token
+# validate twostep form and create a new token
sub create
{
+ my ($template_file, $form, $email_subject_file, $email_body_file, $email_get, $errors_get, $data_get) = @_;
my $ok = $form->validate($Request{args});
if ($ok) {
- my $email = $Request{args}{email};
+ my $email = $email_get->();
# create a new token
my $token = _create_token($email);
# store it in the database
- my $sth = $Request{dbh}->prepare_cached('INSERT INTO twostep (token, email, datetime) VALUES (?, ?, NOW())');
- $sth->execute($token, $email);
+ my $data;
+ $data = $data_get->() if $data_get;
+ my $sth = $Request{dbh}->prepare_cached('INSERT INTO twostep (token, email, datetime, data) VALUES (?, ?, NOW(), ?)');
+ $sth->execute($token, $email, $data);
$Request{dbh}->commit;
# email it
- _send_email($token, $email);
+ _send_email($email_subject_file, $email_body_file, $token, $email);
- # thanks, user
- my $template = Act::Template::HTML->new();
- $template->variables(email => $email);
- $template->process('twostep/ok');
+ # return success
+ return 1;
}
else {
# map errors
- my @errors;
- $form->{invalid}{email} eq 'required' && push @errors, 'ERR_EMAIL';
- $form->{invalid}{email} eq 'email' && push @errors, 'ERR_EMAIL_SYNTAX';
+ my $errors = $errors_get->();
# display form again
- _display_form(\@errors, $form->{fields});
+ _display_form($template_file, $errors, $form->{fields});
+
+ # return error
+ return 0;
}
}
@@ -77,7 +74,10 @@ sub verify_form
{
# do we have an authentication token in the uri?
my $token = $Request{path_info};
- return $token if $token && _exists($token);
+ if ($token) {
+ my $data = _exists($token);
+ return ($token, $$data) if $data;
+ }
$Request{status} = FORBIDDEN;
return;
}
@@ -92,27 +92,27 @@ sub remove
$Request{dbh}->commit;
}
-# display the email address form
+# display the twostep form
sub _display_form
{
- my ($errors, $fields) = @_;
+ my ($template_file, $errors, $fields) = @_;
my $template = Act::Template::HTML->new();
$template->variables(errors => $errors) if $errors;
$template->variables(%$fields) if $fields;
- $template->process('twostep/form');
+ $template->process($template_file);
}
-# returns true if token exists in database
+# returns twostep data if token exists in database
sub _exists
{
my $token = shift;
- my $sth = $Request{dbh}->prepare_cached('SELECT token FROM twostep WHERE token = ?');
+ my $sth = $Request{dbh}->prepare_cached('SELECT token, data FROM twostep WHERE token = ?');
$sth->execute($token);
- (my $found) = $sth->fetchrow_array();
+ my ($found, $data) = $sth->fetchrow_array();
$sth->finish;
- return $found;
+ return $found ? \$data : undef;
}
# create a new token
@@ -130,12 +130,12 @@ sub _create_token
# send email with link embedding token
sub _send_email
{
- my ($token, $email) = @_;
+ my ($email_subject_file, $email_body_file, $token, $email) = @_;
# generate subject and body from templates
my $template = Act::Template->new;
my $subject;
- $template->process("core/twostep/email_subject", \$subject);
+ $template->process($email_subject_file, \$subject);
chomp $subject;
my $body;
@@ -144,7 +144,7 @@ sub _send_email
token => $token,
link => $Request{base_url} . join('/', self_uri(), $token),
);
- $template->process("core/twostep/email_body", \$body);
+ $template->process($email_body_file, \$body);
# send the email
Act::Email::send(
@@ -167,10 +167,20 @@ Act::TwoStep - Two-step handler utility routines
Modify an existing form handler to work in two steps:
- my $token;
+ # twostep form
+ my $twostep_form = Act::Form->new(
+ required => [qw(email)],
+ filters => { email => sub { lc shift } },
+ constraints => { email => 'email' },
+ );
+ # twostep template filename
+ my $twostep_template = 'user/twostep_add';
+
+ ...
+
if ($Request{args}{ok}) { # form has been submitted
# must have a valid twostep token
- $token = Act::TwoStep::verify_form()
+ my ($token, $token_data) = Act::TwoStep::verify_form()
or return;
...
# if form is valid, remove token
@@ -183,12 +193,26 @@ Modify an existing form handler to work in two steps:
}
elsif ($Request{args}{twostepsubmit}) { # two-step form has been submitted
# validate form and create a new token
- Act::TwoStep::create();
+ if (Act::TwoStep::create(
+ $twostep_template, $twostep_form,
+ $twostep_email_subject_template, $twostep_email_body_template,
+ sub { $twostep_form->{fields}{email} },
+ sub { my @errors;
+ $twostep_form->{invalid}{email} eq 'required' && push @errors, 'ERR_EMAIL';
+ $twostep_form->{invalid}{email} eq 'email' && push @errors, 'ERR_EMAIL_SYNTAX';
+ return \@errors;
+ },
+ sub { $token_data },
+ )) {
+ # twostep form is valid, display confirmation page
+ $template->variables(email => $twostep_form->{fields}{email});
+ $template->process('user/twostep_add_ok');
+ }
return;
}
else {
# do we have a twostep token in the uri?
- $token = Act::TwoStep::verify_uri();
+ Act::TwoStep::verify_uri($twostep_template)
or return;
}
# display form
@@ -203,25 +227,26 @@ back to the handler. The link embeds an authentication token.
=over 4
-=item $token = verify_uri()
+=item $token = verify_uri($twostep_template)
Returns token if present in pathinfo and exists in database,
-otherwise displays a form with an email address field and returns undef.
+otherwise displays a form using the supplied $twostep_template and returns undef.
Your handler should return after calling this function if it returns undef;
-=item $token = verify_form()
+=item ($token, $token_data) = verify_form()
-Returns token if present in submitted form data and exists in database,
+Returns token and optional token data if present in submitted form data and exists in database,
otherwise sets the handler return status to FORBIDDEN and returns undef,
-Your handler should return after calling this function if it returns undef;
+Your handler should return after calling this function if it returns undef.
-=item create()
+=item create($twostep_template_file, $twostep_form, $email_subject_file, $email_body_file, $email_get, $errors_get, $toen_data_get)
-Validates the submitted email address, creates a new token in the database,
+Validates the submitted twostep form, creates a new token in the database,
and sends an email back to the user with a link embedding the token,
and displays an acknowledgement page.
+$token_data is an optional sub that returns data that will later be retrived with C<verify_form()>.
Your handler should return after calling this function.
View
21 po/en.po
@@ -607,7 +607,14 @@ msgstr "Update Photo"
msgid "Someone, possibly you, has requested that your password be reset."
msgstr ""
"Someone, possibly you, has requested that your password be reset.\n"
-"Your new password is: %1\n"
+"In order to complete this operation, please click on the following link:\n"
+
+msgid "If you have received this message without having requested it, it is"
+msgstr ""
+"If you have received this message without having requested it, it is\n"
+"because someone attempted to use your username or email address. It\n"
+"was mostly likely an innocent mistake, and they are not getting your\n"
+"password, so you can safely disregard this message.\n"
msgid "New password"
msgstr "Reset password"
@@ -615,19 +622,16 @@ msgstr "Reset password"
msgid "Reset Password"
msgstr "Reset Password"
-msgid "Your password has been reset and emailed to you."
-msgstr "Your password has been reset and emailed to you."
-
msgid "Specify either your login, or your email address."
msgstr ""
"Specify either your <B>login</B>, or your <B>email address</B>.\n"
-"A new password will be created and emailed to you.\n"
+"You will receive an email with instructions on how to reset your password.\n"
msgid "No user was found with this login or email address"
msgstr "No user was found with this login or email address"
msgid "Specify a login, or an email address, but not both"
-msgstr "Specify a login, or an email address, but not both"
+msgstr "Specify a login, or an email address (but not both)"
msgid "Generate password"
msgstr "Reset password"
@@ -1263,3 +1267,8 @@ msgstr "New password"
msgid "Enter your new password twice"
msgstr "Enter your new password twice"
+msgid "An email has been sent to you. Click on the link in the email to"
+msgstr ""
+"An email has been sent to you. Click on the link in the email to\n"
+"access your user account and set a new password.\n"
+
View
18 po/fr.po
@@ -617,7 +617,13 @@ msgstr "Modifier photo"
msgid "Someone, possibly you, has requested that your password be reset."
msgstr ""
"Quelqu'un, peut-être vous, a demandé à changer votre mot de passe.\n"
-"Votre nouveau mot de passe est : %1\n"
+"Pour terminer l'opération, veuillez cliquer sur le lien suivant :\n"
+
+msgid "If you have received this message without having requested it, it is"
+msgstr ""
+"Si vous avez reçu ce message sans en avoir fait la demande, c'est que quelqu'un\n"
+"a utilisé votre login ou votre adresse email. Il s'agit très probablement\n"
+"d'une erreur, et vous pouvez ignorer ce message.\n"
msgid "New password"
msgstr "Nouveau mot de passe"
@@ -625,13 +631,10 @@ msgstr "Nouveau mot de passe"
msgid "Reset Password"
msgstr "Changer de mot de passe"
-msgid "Your password has been reset and emailed to you."
-msgstr "Un nouveau mot de passe a été généré, et vous a été envoyé par email."
-
msgid "Specify either your login, or your email address."
msgstr ""
"Spécifiez votre <b>identifiant</b> ou votre <b>adresse email</b>.\n"
-"Un nouveau mot de passe sera généré et vous sera envoyé par email.\n"
+"Vous recevrez un email vous expliquant comment créer un nouveau mot de passe.\n"
msgid "No user was found with this login or email address"
msgstr "Aucun utilisateur avec cet identifiant ou adresse email."
@@ -1223,3 +1226,8 @@ msgstr "Nouveau mot de passe"
msgid "Enter your new password twice"
msgstr "Veuillez saisir votre nouveau mot de passe deux fois"
+msgid "An email has been sent to you. Click on the link in the email to"
+msgstr ""
+"Un email vous a été envoyé. Cliquez sur le lien contenu dans cet\n"
+"email pour accéder à votre compte et saisir un nouveau mot de passe.\n"
+
View
22 t/form.t
@@ -320,6 +320,28 @@ my @tests = (
},
],
},
+{ profile => {
+ optional => [ qw(r1 r2) ],
+ global => [ sub { $_[0]{r1} && !$_[0]{r2}
+ ||
+ !$_[0]{r1} && $_[0]{r2}
+ }
+ ],
+ desc => 'global',
+ },
+ inputs => [
+ { input => { r1 => 1, r2 => 0 },
+ fields => { r1 => 1, r2 => 0 },
+ valid => 1,
+ desc => 'good',
+ },
+ { input => { r1 => 1, r2 => 2 },
+ fields => { r1 => 1, r2 => 2 },
+ valid => '',
+ desc => 'bad',
+ },
+ ],
+},
);
plan tests => 1 + scalar(@tests) + 3 * sum map scalar(@{$_->{inputs}}), @tests;
View
2  templates/login
@@ -46,7 +46,7 @@
</form>
-<p>[% loc('Forgot your password?', make_uri('resetpw')) %]</p>
+<p>[% loc('Forgot your password?', make_uri('changepwd')) %]</p>
<p>
<font size="-1">
View
7 templates/twostep/form
@@ -1,7 +0,0 @@
-[% WRAPPER ui title = loc("Confirmation required") %]
-
-<p>{{This operation requires a confirmation. Please enter your email address,}}</p>
-
-[% PROCESS core/twostep/form %]
-
-[% END %]
View
5 templates/twostep/ok
@@ -1,5 +0,0 @@
-[% WRAPPER ui title = loc("Confirmation email sent") %]
-
-[% PROCESS core/twostep/ok %]
-
-[% END %]
View
1  templates/user/reset_password_body
@@ -1 +0,0 @@
-[% loc("Someone, possibly you, has requested that your password be reset.", passwd) %]
View
6 templates/core/twostep/form → templates/user/twostep_add
@@ -1,3 +1,7 @@
+[% WRAPPER ui title = loc("Confirmation required") %]
+
+<p>{{This operation requires a confirmation. Please enter your email address,}}</p>
+
[% PROCESS common %]
[% PROCESS error
msgs = {
@@ -26,3 +30,5 @@
</td></tr></table>
</form>
+
+[% END %]
View
0  templates/core/twostep/email_body → templates/user/twostep_add_email_body
File renamed without changes
View
0  templates/core/twostep/email_subject → templates/user/twostep_add_email_subject
File renamed without changes
View
4 templates/core/twostep/ok → templates/user/twostep_add_ok
@@ -1 +1,5 @@
+[% WRAPPER ui title = loc("Confirmation email sent") %]
+
<p>[% loc("An email has been sent to <email>. Click on the link in the email to", email) %]</p>
+
+[% END %]
View
12 templates/user/resetpassword → templates/user/twostep_change_password
@@ -1,13 +1,8 @@
[% WRAPPER ui title = loc('Reset Password') %]
-[% IF reset %]
-<p>
- {{Your password has been reset and emailed to you.}}
-</p>
-[% ELSE %]
<p>
{{Specify either your login, or your email address.}}
</p>
-<center>
+<div align="center">
[% PROCESS error
msgs = {
@@ -39,13 +34,12 @@
</tr>
<tr>
<td colspan="3" align="right">
- <input type="submit" name="ok" value="{{Generate password}}" />
+ <input type="submit" name="twostepsubmit" value="{{Generate password}}" />
</td>
</tr>
</table>
</td></tr></table>
</form>
-</center>
-[% END %]
+</div>
[% END %]
View
4 templates/user/twostep_change_password_email_body
@@ -0,0 +1,4 @@
+{{Someone, possibly you, has requested that your password be reset.}}
+[% link %]
+
+{{If you have received this message without having requested it, it is}}
View
0  templates/user/reset_password_subject → ...ser/twostep_change_password_email_subject
File renamed without changes
View
5 templates/user/twostep_change_password_ok
@@ -0,0 +1,5 @@
+[% WRAPPER ui title = loc('Reset Password') %]
+<p>
+ {{An email has been sent to you. Click on the link in the email to}}
+</p>
+[% END %]
Please sign in to comment.
Something went wrong with that request. Please try again.