aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth/Profile.pm3
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm8
-rw-r--r--t/app/controller/auth.t4
3 files changed, 13 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth/Profile.pm b/perllib/FixMyStreet/App/Controller/Auth/Profile.pm
index 91ffac205..a1bbfc570 100644
--- a/perllib/FixMyStreet/App/Controller/Auth/Profile.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth/Profile.pm
@@ -74,7 +74,8 @@ sub change_password : Path('/auth/change_password') {
if ($c->user->password) {
# we should have a usable password - save it to the user
- $c->user->obj->update( { password => $new } );
+ $c->user->obj->password($new);
+ $c->user->obj->update;
$c->stash->{password_changed} = 1;
} else {
# Set up arguments for code sign in
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 805ea4776..9554bbe7e 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -167,6 +167,14 @@ __PACKAGE__->add_columns(
},
);
+around password => sub {
+ my ($orig, $self) = (shift, shift);
+ if (@_) {
+ $self->set_extra_metadata(last_password_change => time());
+ }
+ $self->$orig(@_);
+};
+
=head2 username
Returns a verified email or phone for this user, preferring email,
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t
index cd72ab550..899b64198 100644
--- a/t/app/controller/auth.t
+++ b/t/app/controller/auth.t
@@ -95,8 +95,10 @@ $mech->not_logged_in_ok;
# visit the confirm link and check user is confirmed
$mech->get_ok($link);
- ok get_user(), "user created";
+ my $user = get_user();
+ ok $user, "user created";
is $mech->uri->path, '/my', "redirected to the 'my' section of site";
+ ok $user->get_extra_metadata('last_password_change'), 'password change set';
$mech->logged_in_ok;
# logout