« Jifty/Plugin/Authentication/Password/Mixin/Model/User.pm
↑ Summary
Jifty/Web/Form/Field/DateTime.pm »
| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | =head1 NAME | ||
| 5 | |||
| 6 | Jifty::Plugin::Authentication::Password::Action::ConfirmEmail - Confirm a user's email address | ||
| 7 | |||
| 8 | =head1 DESCRIPTION | ||
| 9 | |||
| 10 | This is the link in a user's email to confirm that their email | ||
| 11 | email is really theirs. It is not really meant to be rendered on any | ||
| 12 | web page, but is used by the confirmation notification. | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | package Jifty::Plugin::Authentication::Password::Action::ConfirmEmail; | ||
| 17 | use base qw/Jifty::Action/; | ||
| 18 | |||
| 19 | =head2 arguments | ||
| 20 | |||
| 21 | A null sub, because the superclass wants to make sure we fill in arguments | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | sub arguments { } | ||
| 26 | |||
| 27 | =head2 take_action | ||
| 28 | |||
| 29 | Set their confirmed status. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub take_action { | ||
| 34 | my $self = shift; | ||
| 35 | my $LoginUser = Jifty->app_class('Model', 'User'); | ||
| 36 | my $CurrentUser = Jifty->app_class('CurrentUser'); | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | my $u = $LoginUser->new( current_user => $CurrentUser->superuser ); | ||
| 41 | $u->load_by_cols(id => Jifty->web->current_user->user_object->id ); | ||
| 42 | |||
| 43 | if ( $u->email_confirmed ) { | ||
| 44 | $self->result->error( email => _("You have already confirmed your account.") ); | ||
| 45 | $self->result->success(1); # but the action is still a success | ||
| 46 | return 1; | ||
| 47 | } | ||
| 48 | |||
| 49 | my ($val,$msg) = $u->set_email_confirmed('1') ; | ||
| 50 | |||
| 51 | unless ($val) { | ||
| 52 | $self->result->error($msg); | ||
| 53 | return undef; | ||
| 54 | } | ||
| 55 | |||
| 56 | # Set up our login message | ||
| 57 | $self->result->message( _("Welcome to %1, %2." , Jifty->config->framework('ApplicationName') , $u->name) ." " | ||
| 58 | . _(". Your email address has now been confirmed.") ); | ||
| 59 | |||
| 60 | # Actually do the login thing. | ||
| 61 | Jifty->web->current_user( $CurrentUser->new( id => $u->id ) ); | ||
| 62 | return 1; | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; |