Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
3,920 additions
and
1,473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ sub delete_process { | |
|
||
$process->delete; | ||
|
||
return; | ||
return 1; | ||
} | ||
|
||
sub list_process_types { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package LIMS2::WebApp::Controller::User::UserPreferences; | ||
use Moose; | ||
use namespace::autoclean; | ||
use Try::Tiny; | ||
|
||
BEGIN {extends 'Catalyst::Controller'; } | ||
|
||
=head1 NAME | ||
LIMS2::WebApp::Controller::User::UserPreferences - Catalyst Controller | ||
=head1 DESCRIPTION | ||
Catalyst Controller. | ||
=head1 METHODS | ||
=cut | ||
|
||
# Need to have edit writes to make any changes in db, including password | ||
# so users with only the read role can not change their password at the moment | ||
# TODO: see if there is a way to get around this if its worth doing | ||
sub begin :Private { | ||
my ( $self, $c ) = @_; | ||
|
||
$c->assert_user_roles( 'edit' ); | ||
return; | ||
} | ||
|
||
sub change_password :Path( '/user/change_password' ) :Args(0) { | ||
my ( $self, $c ) = @_; | ||
|
||
my $params = $c->request->params; | ||
|
||
return unless $params->{change_password}; | ||
|
||
unless ( $params->{new_password} ) { | ||
$c->stash->{error_msg} = 'You must specify a new password'; | ||
return; | ||
} | ||
|
||
unless ( $params->{new_password_confirm} ) { | ||
$c->stash->{error_msg} = 'You must fill in password confirm box as well'; | ||
return; | ||
} | ||
|
||
unless ( $params->{new_password_confirm} eq $params->{new_password} ) { | ||
$c->stash->{error_msg} = 'new password and password confirm values do not match'; | ||
return; | ||
} | ||
|
||
$c->model('Golgi')->txn_do( | ||
sub { | ||
try{ | ||
my $user = $c->model('Golgi')->change_user_password( | ||
{ id => $c->user->id, | ||
new_password => $params->{new_password}, | ||
new_password_confirm => $params->{new_password_confirm} | ||
} | ||
); | ||
|
||
$c->flash->{success_msg} = 'Password successfully changed for: ' . $user->name ; | ||
$c->res->redirect( $c->uri_for('/') ); | ||
} | ||
catch { | ||
$c->stash->{error_msg} = 'Error encountered while changing password : ' . $_; | ||
$c->model('Golgi')->txn_rollback; | ||
}; | ||
} | ||
); | ||
|
||
return; | ||
} | ||
|
||
=head1 AUTHOR | ||
Sajith Perera | ||
=head1 LICENSE | ||
This library is free software. You can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
=cut | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.