[Bps-public-commit] rt-extension-resetpassword branch, new-user-create-password, repushed
Craig Kaiser
craig at bestpractical.com
Wed Feb 19 12:56:21 EST 2020
The branch new-user-create-password was deleted and repushed:
was 79f1a3957b0a3ba3a8b1dac6e9bedf3bec6aa875
now dc3f86d8567a4b36f3ddc3e7b639c127846eae3b
1: 65b32fc = 1: 65b32fc Move token generation and password reset to lib method
2: d10a07f ! 2: c5262cf Add documentation for config options for allowing a new user to create an account and password
@@ -1,6 +1,6 @@
Author: Craig Kaiser <craig at bestpractical.com>
- Add config options for allowing a new user to create a account and password
+ Add documentation for config options for allowing a new user to create an account and password
diff --git a/README b/README
--- a/README
@@ -9,17 +9,17 @@
being sent, thus not revealing the reasons for any failure. All failures
will still be logged with an appropriate diagnostic message.
-+ $CreateNewsUserAsPrivileged
++ $CreateNewUserAsPrivileged
+ Set this config value to true if users creating a new account should
+ default to privileged users. WARNING Setting this to true can be
+ dangerous as it allows anyone to create a new priviledged user,
+ usually privlidged users are given rights to edit and see information
+ not desired to be public.
+
-+ $CreateNewUserOnPasswordSet
++ $CreateNewUserAndSetPassword
+ This configuration option determines if a nonexistant user can create
+ an new user record. WARNING see the note about the danger of setting
-+ this to true and setting $CreateNewsUserAsPrivileged to true as well.
++ this to true and setting $CreateNewUserAsPrivileged to true as well.
+
AUTHOR
Best Practical Solutions, LLC <modules at bestpractical.com>
@@ -29,34 +29,22 @@
--- a/lib/RT/Extension/ResetPassword.pm
+++ b/lib/RT/Extension/ResetPassword.pm
@@
- sub CreateTokenAndResetPassword {
- my $user = shift;
-
-+ unless ( $user && $user->Id ) {
-+ RT::Logger->error( "Need to provide a loaded RT::User object for CreateTokenAndResetPassword." );
-+ return;
-+ }
-+
- my $token = Digest::MD5->new()->add(
- $user->id,
- $user->__Value('Password'),
-@@
not revealing the reasons for any failure. All failures will still be
logged with an appropriate diagnostic message.
+=over 2
+
-+=item C<$CreateNewsUserAsPrivileged>
++=item C<$CreateNewUserAsPrivileged>
+
+Set this config value to true if users creating a new account should default to privileged users.
+WARNING Setting this to true can be dangerous as it allows anyone to create a new priviledged user,
+usually privlidged users are given rights to edit and see information not desired to be public.
+
+
-+=item C<$CreateNewUserOnPasswordSet>
++=item C<$CreateNewUserAndSetPassword>
+
+This configuration option determines if a nonexistant user can create an new user record.
-+WARNING see the note about the danger of setting this to true and setting C<$CreateNewsUserAsPrivileged>
++WARNING see the note about the danger of setting this to true and setting C<$CreateNewUserAsPrivileged>
+to true as well.
+
+=back
-: ------- > 3: a35354e Check that valid user object is passed to CreateTokenAndResetPassword
3: b84b53b ! 4: ee8b84d Allow new users to create new user accounts and set password
@@ -10,7 +10,7 @@
-<a href="<%$RT::WebPath%>/NoAuth/ResetPassword/Request.html"><&|/l&>Forgot your password?</&></a></div>
+<a href="<%$RT::WebPath%>/NoAuth/ResetPassword/Request.html?Title=<&|/l&>Reset your password</&>"><&|/l&>Forgot your password</&></a></div>
+
-+% if ( RT::Config->Get('CreateNewUserOnPasswordSet') ) {
++% if ( RT::Config->Get('CreateNewUserAndSetPassword') ) {
+ <div id="firstpassword" style="align:left;clear:both;">
+ <a href="<%$RT::WebPath%>/NoAuth/ResetPassword/Request.html?Title=<&|/l&>Create your password</&>"><&|/l&>New account</&></a></div>
+% }
@@ -51,9 +51,9 @@
} else {
- push @actions, loc("RT couldn't find a user with that email address. Give it another try?");
- RT->Logger->warning("Password reset attempted for non-existent user " . $ARGS{'Email'});
-+ if ( RT::Config->Get('CreateNewUserOnPasswordSet') ) {
++ if ( RT::Config->Get('CreateNewUserAndSetPassword') ) {
+ my ($status, $msg) = $u->Create(
-+ Privileged => RT::Config->Get('CreateNewsUserAsPrivileged') || 0,
++ Privileged => RT::Config->Get('CreateNewUserAsPrivileged') || 0,
+ EmailAddress => $ARGS{'Email'},
+ );
+ RT::Logger->error($msg) unless $status;
@@ -79,12 +79,3 @@
pop @actions;
push @actions, loc("RT has sent you an email message with instructions about how to reset your password");
-diff --git a/html/NoAuth/ResetPassword/Reset/dhandler b/html/NoAuth/ResetPassword/Reset/dhandler
---- a/html/NoAuth/ResetPassword/Reset/dhandler
-+++ b/html/NoAuth/ResetPassword/Reset/dhandler
-@@
- <input type ="submit" value ="<%loc('Change password')%>">
- </form>
- %}
--<a href="<%$RT::WebURL|n%>"><&|/l&>Login</&></a>
-
4: 79f1a39 ! 5: e2e772f Allow for an admin to send a password reset email
@@ -1,18 +1,22 @@
Author: Craig Kaiser <craig at bestpractical.com>
Allow for an admin to send a password reset email
+
+ Had to overlay html/Elements/EditPassword to place the send reset
+ password email in a logical place on the page.
diff --git a/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/Modify.html/BeforeCreate b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/Modify.html/BeforeCreate
new file mode 100644
--- /dev/null
+++ b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/Modify.html/BeforeCreate
@@
-+<%init>
++<%INIT>
++# Need to stash the arg as it is not passed to the modify page on redirect
+$session{'SendPasswordResetEmail'} = $ARGSRef->{'SendPasswordResetEmail'};
-+</%init>
-+<%args>
++</%INIT>
++<%ARGS>
+$ARGSRef
-+</%args>
++</%ARGS>
diff --git a/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/Modify.html/BeforeUpdate b/html/Callbacks/RT-Extension-ResetPassword/Admin/Users/Modify.html/BeforeUpdate
new file mode 100644
@@ -29,7 +33,7 @@
+ RT::Logger->error( "$msg" );
+ }
+}
-+$session{'SendPasswordResetEmail'} = undef;
++delete $session{'SendPasswordResetEmail'};
+</%INIT>
+<%ARGS>
+$Results
@@ -127,68 +131,3 @@
+
+</%INIT>
-diff --git a/html/NoAuth/ResetPassword/Request.html b/html/NoAuth/ResetPassword/Request.html
---- a/html/NoAuth/ResetPassword/Request.html
-+++ b/html/NoAuth/ResetPassword/Request.html
-@@
- %# those contributions and any derivatives thereof.
- %#
- %# END BPS TAGGED BLOCK }}}
--<& /Elements/Header, Title => $title &>
-+<& /Elements/Header, Title => $title, Refresh => $refresh &>
- <div id="body" class="login-body">
-
- <h1><%$title%></h1>
-@@
-
- my $title = loc("Reset your password");
-
-+my $refresh;
- if ($ARGS{'Email'}) {
- my $u = RT::User->new($RT::SystemUser);
- $u->LoadByCols(EmailAddress => $ARGS{'Email'});
-@@
- if ($status) {
- push @actions, loc("RT has sent you an email message with instructions about how to reset your password");
- RT->Logger->info("Password reset token send to " . $u->EmailAddress);
-- }
-- else {
-+
-+ $m->notes->{RefreshURL} = RT->Config->Get('WebPath')."/";
-+ $refresh = 1;
-+ } else {
- push @actions, loc("Failed to send password reset token, please contact your RT administrator.");
- RT->Logger->error("Failed to send password reset token to " . $u->EmailAddress . ": $msg");
- }
-
-diff --git a/html/NoAuth/ResetPassword/Reset/dhandler b/html/NoAuth/ResetPassword/Reset/dhandler
---- a/html/NoAuth/ResetPassword/Reset/dhandler
-+++ b/html/NoAuth/ResetPassword/Reset/dhandler
-@@
- my $title = loc('Reset your password');
- my $virtual_path = $m->dhandler_arg();
- my ( $submitted_token, $id ) = split( '/', $virtual_path );
-+my $refresh;
-+
- my $token;
- # Validate the token
- my $u = RT::User->new($RT::SystemUser);
-@@
- {
- my ( $val, $msg ) = $u->SetPassword( $ARGS{'password'} );
- push @results, $msg;
-- if ($val) { $show_form = 0;}
-+ $m->notes->{RefreshURL} = RT->Config->Get('WebPath')."/";
-+ if ($val) { $show_form = 0; $refresh = 1; }
- }
- elsif ( $ARGS{'password'} ) {
- push @results, loc("The two passwords you typed didn't match.");
-@@
-
-
- </%init>
--<& /Elements/Header, Title => $title &>
-+<& /Elements/Header, Title => $title, Refresh => $refresh &>
- <div id="body" class="login-body">
-
- <h1><%$title%></h1>
-: ------- > 6: 255c7bd Add AllowUsersWithoutPassword config option
-: ------- > 7: 8cb1222 Keep the behavior between finding a user and not the same
-: ------- > 8: 56e9025 Center the password links on login page
-: ------- > 9: dc3f86d Fix curly brackets to not be inline
More information about the Bps-public-commit
mailing list