[Jifty-commit] r2126 - in jifty/trunk/plugins/Login:
lib/Jifty/Plugin/Login share/po share/web/templates
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Nov 10 05:04:30 EST 2006
Author: yves
Date: Fri Nov 10 05:04:30 2006
New Revision: 2126
Added:
jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm
jifty/trunk/plugins/Login/share/web/templates/chgpasswd
Modified:
jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm
jifty/trunk/plugins/Login/share/po/fr.po
Log:
Add action change password in login plugin
Added: jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm Fri Nov 10 05:04:30 2006
@@ -0,0 +1,87 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::Login::Action::ChangePassword - Change a password
+
+=head1 DESCRIPTION
+
+This is the action run by /chgpasswd where logged user can change is password.
+
+
+=cut
+
+package Jifty::Plugin::Login::Action::ChangePassword;
+use base qw/Jifty::Action Jifty::Plugin::Login/;
+
+=head2 arguments
+
+ChangePassword has the following fields: password, and password_confirm.
+
+=cut
+
+sub arguments {
+ return (
+ {
+ password => {
+ type => 'password',
+ sticky => 0,
+ label => _('Password')
+ },
+ password_confirm => {
+ type => 'password',
+ sticky => 0,
+ label => _('type your password again')
+ },
+ }
+ );
+}
+
+=head2 take_action
+
+Change the password.
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $LoginUser = $self->LoginUserClass();
+ my $CurrentUser = $self->CurrentUserClass();
+ my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ $u->load_by_cols( email => Jifty->web->current_user->user_object->email );
+
+ unless ($u) {
+ $self->result->error(
+_("You don't exist. I'm not sure how this happened. Really, really sorry. Please email us!")
+ );
+ }
+
+ my $pass = $self->argument_value('password');
+ my $pass_c = $self->argument_value('password_confirm');
+
+ # Trying to set a password (ie, submitted the form)
+ unless (defined $pass
+ and defined $pass_c
+ and length $pass
+ and $pass eq $pass_c )
+ {
+ $self->result->error(
+_("It looks like you didn't enter the same password into both boxes. Give it another shot?")
+ );
+ return;
+ }
+
+ unless ( $u->set_password($pass) ) {
+ $self->result->error(_("There was an error setting your password."));
+ return;
+ }
+
+ # ok!
+ $self->result->message(_("Your password has been changed. Welcome back."));
+ return 1;
+
+}
+
+1;
+
Modified: jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm
==============================================================================
--- jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm (original)
+++ jifty/trunk/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm Fri Nov 10 05:04:30 2006
@@ -6,6 +6,21 @@
# Put any plugin-specific dispatcher rules here.
+on 'chgpasswd' => run {
+ redirect('/login') if (! Jifty->web->current_user->id );
+ set 'action' =>
+ Jifty->web->new_action(
+ class => 'ChangePassword',
+ moniker => 'chgpasswdbox'
+ );
+
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+
+};
+
+
# Sign up for an account
on 'signup' => run {
redirect('/') if ( Jifty->web->current_user->id );
Modified: jifty/trunk/plugins/Login/share/po/fr.po
==============================================================================
--- jifty/trunk/plugins/Login/share/po/fr.po (original)
+++ jifty/trunk/plugins/Login/share/po/fr.po Fri Nov 10 05:04:30 2006
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2006-10-24 15:00+ZONE\n"
-"PO-Revision-Date: 2006-11-09 14:35+ZONE\n"
+"PO-Revision-Date: 2006-11-10 10:47+ZONE\n"
"Last-Translator: AGOSTINI Yves <agostini at univ-metz.fr>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"MIME-Version: 1.0\n"
@@ -43,10 +43,18 @@
msgid ". Your email address has now been confirmed."
msgstr ". Votre adresse mail a été vérifiée."
-#: lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:94
+#: lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:95
msgid "A link to reset your password has been sent to your email account."
msgstr "Un lien web pour ré-initialiser votre mot de passe vous a été envoyé par mail."
+#: share/web/templates/chgpasswd:11
+msgid "Change"
+msgstr "Valider"
+
+#: share/web/templates/chgpasswd:6
+msgid "Change your password"
+msgstr "Changer votre mot de passe"
+
#: lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:94
msgid "Confirmation resent."
msgstr "Demande de confirmation transmise."
@@ -63,7 +71,7 @@
msgid "If you want, your browser can remember your login for you"
msgstr "Si vous le désirez, votre navigateur peut mémoriser votre identification"
-#: lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:74 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:77
+#: lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:74 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:78
msgid "It doesn't look like there's an account by that name."
msgstr "Ce compte ne semble pas exister."
@@ -71,7 +79,7 @@
msgid "It looks like you already have an account. Perhaps you want to <a href=\"/login\">sign in</a> instead?"
msgstr "Vous semblez avoir déjà un compte. Vous désirez peut-être plutôt vous <a href=\"/login\">identifier</a> ?"
-#: lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:68
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:70 lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:68
msgid "It looks like you didn't enter the same password into both boxes. Give it another shot?"
msgstr "Les mots de passe semblent différents. Ré-essayer ?"
@@ -95,7 +103,7 @@
msgid "Ok, you're now logged out. Have a good day."
msgstr "Vous êtes déconnecté. Au revoir."
-#: lib/Jifty/Plugin/Login/Action/Login.pm:30
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:30 lib/Jifty/Plugin/Login/Action/Login.pm:30
msgid "Password"
msgstr "Mot de passe"
@@ -111,11 +119,11 @@
msgid "Something bad happened and we couldn't create your account. Try again later. We're really, really sorry."
msgstr "Votre compte ne peut pas actuellement être créé. Merci de ré-essayer ultérieurement."
-#: lib/Jifty/Plugin/Login/Action/Login.pm:60 lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:67 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:70 lib/Jifty/Plugin/Login/Action/Signup.pm:62
+#: lib/Jifty/Plugin/Login/Action/Login.pm:60 lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:67 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:71 lib/Jifty/Plugin/Login/Action/Signup.pm:62
msgid "That doesn't look like an email address."
msgstr "Cela ne ressemble pas à une adresse mail."
-#: lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:74
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:76 lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:74
msgid "There was an error setting your password."
msgstr "Erreur lors de la création de votre mot de passe."
@@ -131,7 +139,7 @@
msgid "Welcome to "
msgstr "Bienvenue sur "
-#: lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:54
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:56 lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:54
msgid "You don't exist. I'm not sure how this happened. Really, really sorry. Please email us!"
msgstr "Vous n'existez pas !!!"
@@ -151,14 +159,18 @@
msgid "You're already logged in."
msgstr "Vous êtes déjà connecté."
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:81
+msgid "Your password has been changed. Welcome back."
+msgstr ""
+
#: lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:79
msgid "Your password has been reset. Welcome back."
msgstr "Votre mot de passe a été ré-initialisé. Bon retour."
-#: lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:31 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:33
+#: lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm:31 lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm:34
msgid "email address"
msgstr "adresse mail"
-#: lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:33
+#: lib/Jifty/Plugin/Login/Action/ChangePassword.pm:35 lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm:33
msgid "type your password again"
msgstr "confirmez votre mot de passe"
Added: jifty/trunk/plugins/Login/share/web/templates/chgpasswd
==============================================================================
--- (empty file)
+++ jifty/trunk/plugins/Login/share/web/templates/chgpasswd Fri Nov 10 05:04:30 2006
@@ -0,0 +1,13 @@
+<%args>
+$action
+$next
+</%args>
+<&|/_elements/wrapper, title => 'Change your password' &>
+<h2><% _("Change your password") %></h2>
+<% Jifty->web->form->start(call => $next, name => "chgpasswdbox") %>
+% foreach my $key ($action->argument_names) {
+<% $action->form_field($key) %>
+% }
+<% Jifty->web->form->submit(label => _('Change'), submit => $action) %>
+<% Jifty->web->form->end %>
+</&>
More information about the Jifty-commit
mailing list