mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
Allow admin to reset password instead of resend invite
This commit is contained in:
parent
0dccaa9ca4
commit
df180a2cb8
@ -315,9 +315,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
$scope.resendInvite= function() {
|
||||
$http.post('api/users/' + $scope.user.id + '/invite').success(function(user) {
|
||||
$scope.user.inviteLink = user.invite_link;
|
||||
$scope.sendPasswordReset = function() {
|
||||
$scope.disablePasswordResetButton = true;
|
||||
$http.post('api/users/' + $scope.user.id + '/reset_password').success(function(user) {
|
||||
$scope.disablePasswordResetButton = false;
|
||||
growl.addSuccessMessage("The user should receive a link to reset his password by email soon.")
|
||||
});
|
||||
};
|
||||
};
|
||||
|
@ -20,17 +20,7 @@
|
||||
</p>
|
||||
<div ng-if="currentUser.isAdmin">
|
||||
<hr/>
|
||||
<button class="btn btn-default" ng-if="!user.inviteLink" ng-click="resendInvite()">Resend Invite</button>
|
||||
|
||||
<div ng-if="user.inviteLink" class="alert alert-success">
|
||||
<p>
|
||||
<strong>{{ user.name }} should receive an invite email soon.</strong>
|
||||
</p>
|
||||
<p>
|
||||
You can use the following link to invite them yourself:<br/>
|
||||
{{user.inviteLink}}
|
||||
</p>
|
||||
</div>
|
||||
<button class="btn btn-default" ng-click="sendPasswordReset()" ng-disabled="disablePasswordResetButton">Send Password Reset Email</button>
|
||||
</div>
|
||||
</tab>
|
||||
<tab heading="API Key" ng-if="user.api_key" active="tabs['apiKey']" select="setTab('apiKey')">
|
||||
|
@ -52,5 +52,6 @@ def send_password_reset_email(user):
|
||||
subject = u"Reset your password"
|
||||
|
||||
send_mail.delay([user.email], subject, html_content, text_content)
|
||||
return reset_link
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ from redash.handlers.data_sources import DataSourceTypeListResource, DataSourceL
|
||||
from redash.handlers.events import EventResource
|
||||
from redash.handlers.queries import QueryRefreshResource, QueryListResource, QueryRecentResource, QuerySearchResource, QueryResource
|
||||
from redash.handlers.query_results import QueryResultListResource, QueryResultResource, JobResource
|
||||
from redash.handlers.users import UserResource, UserListResource, UserInviteResource
|
||||
from redash.handlers.users import UserResource, UserListResource, UserInviteResource, UserResetPasswordResource
|
||||
from redash.handlers.visualizations import VisualizationListResource
|
||||
from redash.handlers.visualizations import VisualizationResource
|
||||
from redash.handlers.widgets import WidgetResource, WidgetListResource
|
||||
@ -77,6 +77,7 @@ api.add_org_resource(JobResource, '/api/jobs/<job_id>', endpoint='job')
|
||||
api.add_org_resource(UserListResource, '/api/users', endpoint='users')
|
||||
api.add_org_resource(UserResource, '/api/users/<user_id>', endpoint='user')
|
||||
api.add_org_resource(UserInviteResource, '/api/users/<user_id>/invite', endpoint='user_invite')
|
||||
api.add_org_resource(UserResetPasswordResource, '/api/users/<user_id>/reset_password', endpoint='user_reset_password')
|
||||
|
||||
api.add_org_resource(VisualizationListResource, '/api/visualizations', endpoint='visualizations')
|
||||
api.add_org_resource(VisualizationResource, '/api/visualizations/<visualization_id>', endpoint='visualization')
|
||||
|
@ -9,7 +9,7 @@ from redash.permissions import require_permission, require_admin_or_owner, is_ad
|
||||
require_permission_or_owner, require_admin
|
||||
from redash.handlers.base import BaseResource, require_fields, get_object_or_404
|
||||
|
||||
from redash.authentication.account import invite_link_for_user, send_invite_email
|
||||
from redash.authentication.account import invite_link_for_user, send_invite_email, send_password_reset_email
|
||||
|
||||
|
||||
def invite_user(org, inviter, user):
|
||||
@ -68,6 +68,13 @@ class UserInviteResource(BaseResource):
|
||||
return d
|
||||
|
||||
|
||||
class UserResetPasswordResource(BaseResource):
|
||||
@require_admin
|
||||
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)
|
||||
|
||||
|
||||
class UserResource(BaseResource):
|
||||
def get(self, user_id):
|
||||
require_permission_or_owner('list_users', user_id)
|
||||
|
@ -419,4 +419,4 @@ def send_mail(to, subject, html, text):
|
||||
|
||||
mail.send(message)
|
||||
except Exception:
|
||||
logger.exception('Failed sending message: ', message.subject)
|
||||
logger.exception('Failed sending message: %s', message.subject)
|
||||
|
Loading…
Reference in New Issue
Block a user