|
|
|
|
@ -1,12 +1,24 @@ |
|
|
|
|
package MJB::Web::Controller::UserSettings; |
|
|
|
|
use Mojo::Base 'Mojolicious::Controller', -signatures; |
|
|
|
|
|
|
|
|
|
#== |
|
|
|
|
# GET /profile | show_profile | templates/user_settings/profile.html.ep |
|
|
|
|
#== |
|
|
|
|
sub profile ( $c ) { |
|
|
|
|
# Set the form values from the DB if they don't exist from the POST handler. |
|
|
|
|
$c->stash->{form}->{name} ||= $c->stash->{person}->name; |
|
|
|
|
$c->stash->{form}->{email} ||= $c->stash->{person}->email; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#== |
|
|
|
|
# POST /profile | do_profile |
|
|
|
|
# name | The value to set for the account name |
|
|
|
|
# email | The value to set for the account email |
|
|
|
|
# password | The current password, used to authenticate this request. |
|
|
|
|
# |
|
|
|
|
# This route will change the user's name or email address. They are required |
|
|
|
|
# to submit their current password to make these changes. |
|
|
|
|
#== |
|
|
|
|
sub do_profile ( $c ) { |
|
|
|
|
my $name = $c->stash->{form}->{name} = $c->param('name'); |
|
|
|
|
my $email = $c->stash->{form}->{email} = $c->param('email'); |
|
|
|
|
@ -38,8 +50,21 @@ sub do_profile ( $c ) { |
|
|
|
|
$c->redirect_to( $c->url_for( 'show_profile' ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub change_password ( $c ) { } |
|
|
|
|
#== |
|
|
|
|
# GET /change_password | show_change_password | templates/user_settings/change_password.html.ep |
|
|
|
|
#== |
|
|
|
|
sub change_password ( $c ) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#== |
|
|
|
|
# POST /change_password | do_change_password |
|
|
|
|
# password | The current password, used to authenticate this request. |
|
|
|
|
# new_password | The new password to set for the account. |
|
|
|
|
# password_confirm | Confirmation of the new password, it must match. |
|
|
|
|
# |
|
|
|
|
# This route will update the user's password. |
|
|
|
|
#== |
|
|
|
|
sub do_change_password ( $c ) { |
|
|
|
|
# Get the values the user gave for the password change. |
|
|
|
|
my $password = $c->stash->{form}->{password} = $c->param('password'); |
|
|
|
|
|