Skip to content

Commit

Permalink
Display user's password reset link to the admin
Browse files Browse the repository at this point in the history
Similarly to when we invite new users, this allows the admin to reset the
password herself (or send it manually to the user), in cases where there's some
issue sending the e-mail.
  • Loading branch information
vitorbaptista committed Nov 2, 2016
1 parent 2f09043 commit 72389b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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
10 changes: 10 additions & 0 deletions rd_ui/app/views/users/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ <h3 class="p-l-5">{{user.name}}</h3>
<button class="btn btn-default" ng-click="sendPasswordReset()" ng-disabled="disablePasswordResetButton">Send
Password Reset Email
</button>

<div ng-if="passwordResetLink && !disablePasswordResetButton" class="alert alert-success">
<p>
<strong>The user should receive a link to reset his password by email soon.</strong>
</p>
<p ng-if="clientConfig.mailSettingsMissing">
You can use the following link to reset the password yourself:<br/>
{{passwordResetLink}}
</p>
</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

0 comments on commit 72389b0

Please sign in to comment.