1 | package LATMOS::Accounts::Web::Controller::PwRst; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN { extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | LATMOS::Accounts::Web::Controller::PwRst - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | sub begin : Private { |
---|
20 | my ( $self, $c ) = @_; |
---|
21 | |
---|
22 | $c->model('Accounts')->db->SetConnectedUser('$ROOT'); |
---|
23 | $c->stash->{user} = $c->model('Accounts')->db->get_object('user', 'thauvin'); |
---|
24 | $c->log->debug('Allow ' . $c->model('Accounts')->db->check_acl($c->stash->{user}, 'userPassword', 'w')); |
---|
25 | |
---|
26 | return 1; |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | =head2 index |
---|
31 | |
---|
32 | =cut |
---|
33 | |
---|
34 | sub index :Path :Args(0) { |
---|
35 | my ( $self, $c ) = @_; |
---|
36 | |
---|
37 | $c->stash->{Nosync} = 1; |
---|
38 | |
---|
39 | if ( my $user = $c->req->param('user') ) { |
---|
40 | $c->forward('/remote/askpwreset/index'); |
---|
41 | if ($c->stash->{data}{err}) { |
---|
42 | $c->log->error( |
---|
43 | sprintf( |
---|
44 | 'Request from %s to reset password for user %s failed: %s', |
---|
45 | $c->req->address, |
---|
46 | $user, |
---|
47 | $c->stash->{data}{err} |
---|
48 | ) |
---|
49 | ); |
---|
50 | } elsif ( $c->stash->{data}{ok} eq 'Done' ) { |
---|
51 | $c->log->info( |
---|
52 | sprintf( |
---|
53 | 'Request from %s to reset password for user %s Sent', |
---|
54 | $c->req->address, |
---|
55 | $user, |
---|
56 | ) |
---|
57 | ); |
---|
58 | } |
---|
59 | |
---|
60 | $c->go('reqdone'); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | sub changepw :Path :Args(1) { |
---|
65 | my ( $self, $c, $reqid ) = @_; |
---|
66 | |
---|
67 | $c->stash->{ReqId} = $reqid; |
---|
68 | |
---|
69 | my $password = $c->req->param('password') || ''; |
---|
70 | my $cpassword = $c->req->param('cpassword') || ''; |
---|
71 | |
---|
72 | if ($password) { |
---|
73 | if ($password ne $cpassword) { |
---|
74 | $c->stash->{data}{err} = $c->localize('Password are differents'); |
---|
75 | return; |
---|
76 | } |
---|
77 | |
---|
78 | $c->forward('/remote/pwreset/index'); |
---|
79 | |
---|
80 | if ( $c->stash->{data}{ok} eq 'Done' ) { |
---|
81 | $c->go('changedone'); |
---|
82 | } |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | sub reqdone : Private { |
---|
87 | my ( $self, $c ) = @_; |
---|
88 | } |
---|
89 | |
---|
90 | sub changedone : Private { |
---|
91 | my ( $self, $c ) = @_; |
---|
92 | } |
---|
93 | |
---|
94 | =encoding utf8 |
---|
95 | |
---|
96 | =head1 AUTHOR |
---|
97 | |
---|
98 | Olivier Thauvin,Guyancourt-B1428,+33 1 80285052, |
---|
99 | |
---|
100 | =head1 LICENSE |
---|
101 | |
---|
102 | This library is free software. You can redistribute it and/or modify |
---|
103 | it under the same terms as Perl itself. |
---|
104 | |
---|
105 | =cut |
---|
106 | |
---|
107 | __PACKAGE__->meta->make_immutable; |
---|
108 | |
---|
109 | 1; |
---|