Clean up user editing
[?]
Nov 5, 2013, 1:02 PM
4AKMU4ZB2RYJWUDM4H2WW42MVMDWZZ4YD45FJ64DIS77TO56THZACDependencies
- [2]
MQMF2LBWRe-enable adding new users via the web interface - [3]
WDKFN4B2Make sign in a modal dialog box rather than a separate page - [4]
PZL3SZM3Give every page a consistent title - [5]
2G63HKCHFix some wellformedness issues - [6]
SZYDW2DGhydra: added some user admin - [7]
JARRBLZDBootstrapify the Hydra forms (except the project and jobset edit pages) - [8]
LZVO64YGMerge in the first bits of the API work - [9]
SYLVCTT6Start api cleanup with the User model - [10]
LSZLZHJYAllow users to edit their own settings - [11]
AWMM5OGVUse delete instead of delete_all - [12]
LYVUXIGTClean up the authorization code a bit - [13]
XUKHBDR5Prevent Persona users from setting a password - [14]
7KF7YZDRDisable account creation for now - [15]
LCLCU6FNDon't show a password reset button for Persona accounts - [16]
D44B24QCStore the account type ("hydra" or "persona") explicitly in the database - [17]
36ZTCZ4FAdd basic Persona support - [18]
3PNG7NIBRemove trailing whitespace - [19]
XJRJ4J7MAdd user registration - [*]
2P7VNAACMove common Javascript code into a separate file - [*]
TQVKZQUGUse the REST API in the web interface for editing jobsets
Change contents
- replacement in src/lib/Hydra/Controller/User.pm at line 19
sub login :Local :Args(0) :ActionClass('REST::ForBrowsers') { }sub login :Local :Args(0) :ActionClass('REST') { } - replacement in src/lib/Hydra/Controller/User.pm at line 33
$self->status_ok($c, entity => { });$self->status_no_content($c); - replacement in src/lib/Hydra/Controller/User.pm at line 37
sub logout :Local :Args(0) :ActionClass('REST::ForBrowsers') { }sub logout :Local :Args(0) :ActionClass('REST') { } - replacement in src/lib/Hydra/Controller/User.pm at line 109
$c->stash->{template} = 'user.tt';$c->stash->{create} = 1;return if $c->request->method ne "POST";if ($c->request->method eq "GET") {$c->stash->{template} = 'user.tt';$c->stash->{create} = 1;return;}die unless $c->request->method eq "PUT"; - replacement in src/lib/Hydra/Controller/User.pm at line 145
backToReferer($c);$self->status_no_content($c); - edit in src/lib/Hydra/Controller/User.pm at line 151
my $fullName = trim($c->req->params->{fullname} // "");error($c, "Your must specify your full name.") if $fullName eq ""; - edit in src/lib/Hydra/Controller/User.pm at line 165
my $fullName = trim($c->req->params->{fullname} // "");error($c, "Your must specify your full name.") if $fullName eq ""; - replacement in src/lib/Hydra/Controller/User.pm at line 192
$self->status_ok($c,$self->status_ok($c, - replacement in src/lib/Hydra/Controller/User.pm at line 211
sub deleteUser {my ($self, $c, $user) = @_;my ($project) = $c->model('DB::Projects')->search({ owner => $user->username });error($c, "User " . $user->username . " is still owner of project " . $project->name . ".")if defined $project;$c->logout() if $user->username eq $c->user->username;$user->delete;}sub edit :Chained('user') :Args(0) :ActionClass('REST::ForBrowsers') { }sub edit :Chained('user') :PathPart('') :Args(0) :ActionClass('REST::ForBrowsers') { } - edit in src/lib/Hydra/Controller/User.pm at line 215
$c->stash->{template} = 'user.tt';} - edit in src/lib/Hydra/Controller/User.pm at line 218
sub edit_PUT {my ($self, $c) = @_; - replacement in src/lib/Hydra/Controller/User.pm at line 222
$c->stash->{template} = 'user.tt';$c->session->{referer} = $c->request->referer if !defined $c->session->{referer};if (($c->stash->{params}->{submit} // "") eq "reset-password") {return;} - replacement in src/lib/Hydra/Controller/User.pm at line 226
$c->stash->{fullname} = $user->fullname;txn_do($c->model('DB')->schema, sub {updatePreferences($c, $user);}); - replacement in src/lib/Hydra/Controller/User.pm at line 230
$c->stash->{emailonerror} = $user->emailonerror;$c->flash->{successMsg} = "Your preferences have been updated.";$self->status_no_content($c); - replacement in src/lib/Hydra/Controller/User.pm at line 234
sub edit_POST {sub edit_DELETE { - edit in src/lib/Hydra/Controller/User.pm at line 236
- replacement in src/lib/Hydra/Controller/User.pm at line 238
$c->stash->{template} = 'user.tt';my ($project) = $c->model('DB::Projects')->search({ owner => $user->username });error($c, "User " . $user->username . " is still owner of project " . $project->name . ".")if defined $project; - replacement in src/lib/Hydra/Controller/User.pm at line 242
$c->session->{referer} = $c->request->referer if !defined $c->session->{referer};$c->logout() if $user->username eq $c->user->username;$user->delete;$c->flash->{successMsg} = "The user has been deleted.";$self->status_no_content($c);}sub reset_password :Chained('user') :PathPart('reset-password') :Args(0) {my ($self, $c) = @_;my $user = $c->stash->{user}; - replacement in src/lib/Hydra/Controller/User.pm at line 255
if (($c->stash->{params}->{submit} // "") eq "delete") {deleteUser($self, $c, $user);backToReferer($c);}requirePost($c); - replacement in src/lib/Hydra/Controller/User.pm at line 257[4.2358]→[4.25844:25913](∅→∅),[4.25913]→[4.64:150](∅→∅),[4.150]→[4.2427:3040](∅→∅),[4.207]→[4.2427:3040](∅→∅),[4.25913]→[4.2427:3040](∅→∅),[4.2427]→[4.2427:3040](∅→∅)
if (($c->stash->{params}->{submit} // "") eq "reset-password") {error($c, "This user's password cannot be reset.") if $user->type ne "hydra";$c->stash->{json} = {};error($c, "No email address is set for this user.")unless $user->emailaddress;my $password = Crypt::RandPasswd->word(8,10);setPassword($user, $password);sendEmail($c,$user->emailaddress,"Hydra password reset","Hi,\n\n"."Your password has been reset. Your new password is '$password'.\n\n"."You can change your password at " . $c->uri_for($self->action_for('edit'), [$user->username]) . ".\n\n"."With regards,\n\nHydra.\n");return;}error($c, "This user's password cannot be reset.") if $user->type ne "hydra";error($c, "No email address is set for this user.")unless $user->emailaddress; - replacement in src/lib/Hydra/Controller/User.pm at line 261[4.3095]→[4.3095:3137](∅→∅),[4.3137]→[2.1666:1704](∅→∅),[2.1704]→[4.3956:3964](∅→∅),[4.3956]→[4.3956:3964](∅→∅)
txn_do($c->model('DB')->schema, sub {updatePreferences($c, $user);});my $password = Crypt::RandPasswd->word(8,10);setPassword($user, $password);sendEmail($c,$user->emailaddress,"Hydra password reset","Hi,\n\n"."Your password has been reset. Your new password is '$password'.\n\n"."You can change your password at " . $c->uri_for($self->action_for('edit'), [$user->username]) . ".\n\n"."With regards,\n\nHydra.\n"); - replacement in src/lib/Hydra/Controller/User.pm at line 272[4.3965]→[4.26184:26227](∅→∅),[4.26227]→[4.266:339](∅→∅),[4.339]→[4.26227:26311](∅→∅),[4.26227]→[4.26227:26311](∅→∅)
if ($c->request->looks_like_browser) {$c->flash->{successMsg} = "Your preferences have been updated.";backToReferer($c);} else {$self->status_no_content($c);}$c->flash->{successMsg} = "A new password has been sent to ${\$user->emailaddress}.";$self->status_no_content($c); - edit in src/root/static/js/common.js at line 148[22.3901]
function backToReferrer() {// FIXME: should only do this if the referrer is another Hydra// page.window.location = document.referrer;} - replacement in src/root/user.tt at line 1
[% WRAPPER layout.tt title=(create ? "Register new user" : "Editing user $user.username") %][% WRAPPER layout.tt title=(create ? "Add new user" : "Editing user $user.username") %] - replacement in src/root/user.tt at line 17
<form class="form-horizontal" method="post"><form class="form-horizontal"> - replacement in src/root/user.tt at line 33
<input type="text" class="span3" name="fullname" [% HTML.attributes(value => fullname) %]/><input type="text" class="span3" name="fullname" [% HTML.attributes(value => create ? '' : user.fullname) %]/> - replacement in src/root/user.tt at line 63
<input type="checkbox" name="emailonerror" [% IF emailonerror; 'checked="checked"'; END %]/>Receive evaluation error notifications<input type="checkbox" name="emailonerror" [% IF !create && user.emailonerror; 'checked="checked"'; END %]/>Receive evaluation error notifications - replacement in src/root/user.tt at line 96
<button type="submit" class="btn btn-primary"><button id="submit-user" class="btn btn-primary"> - replacement in src/root/user.tt at line 101
<button id="reset-password" type="submit" class="btn btn-warning" name="submit" value="reset-password"><button id="reset-password" class="btn btn-warning"> - edit in src/root/user.tt at line 105
<script type="text/javascript">$("#reset-password").click(function() {bootbox.confirm('Are you sure you want to reset the password for this user?',function(c) {if (!c) return;$.post("[% c.uri_for(c.controller('User').action_for('edit'), [user.username]) %]", { submit: 'reset-password' }).done(function(data) {if (data.error)bootbox.alert("Unable to reset password: " + data.error);elsebootbox.alert("An email containing the new password has been sent to the user.");}).fail(function() { bootbox.alert("Server request failed!"); });});return false;});</script> - replacement in src/root/user.tt at line 107
<button id="delete-user" type="submit" class="btn btn-danger" name="submit" value="delete"><button id="delete-user" class="btn btn-danger"> - edit in src/root/user.tt at line 111
<script type="text/javascript">$("#delete-user").click(function() {return confirm("Are you sure you want to delete this user?");});</script> - edit in src/root/user.tt at line 118
<script>$("#submit-user").click(function() {requestJSON({[% IF create %]url: "[% c.uri_for(c.controller('User').action_for('register')) %]",[% ELSE %]url: "[% c.uri_for(c.controller('User').action_for('edit'), c.req.captures) %]",[% END %]data: $(this).parents("form").serialize(),type: 'PUT',success: backToReferrer});return false;});$("#reset-password").click(function() {bootbox.confirm('Are you sure you want to reset the password for this user?',function(c) {if (!c) return;requestJSON({url: "[% c.uri_for(c.controller('User').action_for('reset_password'), [user.username]) %]",type: 'POST',success: backToReferrer});});return false;});$("#delete-user").click(function() {bootbox.confirm('Are you sure you want to delete this user?',function(c) {if (!c) return;requestJSON({url: "[% c.uri_for(c.controller('User').action_for('edit'), c.req.captures) %]",type: 'DELETE',success: backToReferrer});});return false;});</script>