Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: display user's password reset link to the admin when mail server disabled #1371

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rd_ui/app/scripts/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@

$scope.sendPasswordReset = function() {
$scope.disablePasswordResetButton = true;
$http.post('api/users/' + $scope.user.id + '/reset_password').success(function(user) {
$http.post('api/users/' + $scope.user.id + '/reset_password').success(function(data) {
$scope.disablePasswordResetButton = false;
growl.addSuccessMessage("The user should receive a link to reset his password by email soon.")
$scope.passwordResetLink = data.reset_link;
});
};
};
Expand Down
19 changes: 16 additions & 3 deletions rd_ui/app/views/users/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,22 @@ <h3 class="p-l-5">{{user.name}}</h3>
</p>
<div ng-if="currentUser.isAdmin">
<hr/>
<button class="btn btn-default" ng-click="sendPasswordReset()" ng-disabled="disablePasswordResetButton">Send
Password Reset Email
</button>
<div class="form-group">
<button class="btn btn-default" ng-click="sendPasswordReset()" ng-disabled="disablePasswordResetButton">Send
Password Reset Email
</button>
</div>

<div ng-if="passwordResetLink" class="alert alert-success">
<p ng-if="!clientConfig.mailSettingMissing">
<strong>The user should receive a link to reset his password by email soon.</strong>
</p>
<p ng-if="clientConfig.mailSettingsMissing">
You don't have mail server configured, please send the following link
to {{user.name}} to reset their password:<br/>
<a ng-href="passwordResetLink">{{passwordResetLink}}</a>
</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Let's show the original message ("should receive by email...") only if email is enabled (ng-if="!clientConfig.mailSettingsMissing").
  2. Change the text here to: You don't have mail server configured, please send the following link to {{user.name}} to reset their password:.
  3. To have the reset link as an <a> tag: <a ng-href="passwordResetLink">{{paswordResetLink}}</a>. IIRC, it's a full link so the base href doesn't matter.

</div>
</div>
</div>
<div ng-show="selectedTab == 'apiKey'" class="p-10">
Expand Down
4 changes: 4 additions & 0 deletions redash/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def post(self, user_id):
user = models.User.get_by_id_and_org(user_id, self.current_org)
reset_link = send_password_reset_email(user)

return {
'reset_link': reset_link,
}


class UserResource(BaseResource):
def get(self, user_id):
Expand Down