Skip to content

Commit

Permalink
Merge pull request #1371 from vitorbaptista/feature/show_admins_the_p…
Browse files Browse the repository at this point in the history
…assword_reset_link

Change: display user's password reset link to the admin when mail server disabled
  • Loading branch information
arikfr authored Nov 20, 2016
2 parents a951034 + 3ca78be commit 3b7f167
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 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
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>
</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 3b7f167

Please sign in to comment.