Line | |
---|
1 | package LATMOS::Accounts::Web::Controller::Remote::PwReset; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN { extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | LATMOS::Accounts::Web::Controller::Remote::AskPwReset - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | |
---|
20 | =head2 index |
---|
21 | |
---|
22 | =cut |
---|
23 | |
---|
24 | sub index :Path :Args(0) { |
---|
25 | my ( $self, $c ) = @_; |
---|
26 | |
---|
27 | my $username = $c->req->param('user') or do { |
---|
28 | $c->stash->{data}{err} = 'Invalid request'; |
---|
29 | return; |
---|
30 | }; |
---|
31 | |
---|
32 | my $user = $c->model('Accounts')->db->get_object('user', $username) or do { |
---|
33 | $c->stash->{data}{err} = 'No such user'; |
---|
34 | return; |
---|
35 | }; |
---|
36 | |
---|
37 | if (!$user->_get_attributes('active')) { |
---|
38 | $c->stash->{data}{err} = 'No such user'; |
---|
39 | return; |
---|
40 | } |
---|
41 | |
---|
42 | my $resetid = $c->req->param('id'); |
---|
43 | my $password = $c->req->param('password'); |
---|
44 | |
---|
45 | if (!$user->CheckPasswordResetId($resetid)) { |
---|
46 | $c->stash->{data}{err} = 'Invalid request'; |
---|
47 | return; |
---|
48 | } |
---|
49 | |
---|
50 | my $error = $c->forward('/users/change_password', [ $username, $password ]); |
---|
51 | |
---|
52 | if ($error) { |
---|
53 | $c->stash->{data}{err} = $error; |
---|
54 | return |
---|
55 | } else { |
---|
56 | $user->DeletePasswordId($resetid); |
---|
57 | $user->base->commit; |
---|
58 | $c->stash->{data}{ok} = 'Done'; |
---|
59 | return 1; |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | =encoding utf8 |
---|
66 | |
---|
67 | =head1 AUTHOR |
---|
68 | |
---|
69 | Olivier Thauvin,Guyancourt - B1428,+33 1 80285052, |
---|
70 | |
---|
71 | =head1 LICENSE |
---|
72 | |
---|
73 | This library is free software. You can redistribute it and/or modify |
---|
74 | it under the same terms as Perl itself. |
---|
75 | |
---|
76 | =cut |
---|
77 | |
---|
78 | __PACKAGE__->meta->make_immutable; |
---|
79 | |
---|
80 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.