source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/PwRst.pm @ 2349

Last change on this file since 2349 was 2349, checked in by nanardon, 4 years ago

Add form to reset password using mail feature

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