def initialize_reset_password(self, doc, email): token_ttl = app.config['RESET_PASSWORD_TOKEN_TIME_TO_LIVE'] user = superdesk.get_resource_service('users').find_one(req=None, email=email) if not user: logger.warning( 'User password reset triggered with invalid email: %s' % email) raise SuperdeskApiError.badRequestError('Invalid email') if not user.get('is_enabled', False): logger.warning( 'User password reset triggered for an disabled user') raise SuperdeskApiError.forbiddenError('User not enabled') if not user.get('is_active', False): logger.warning( 'User password reset triggered for an inactive user') raise SuperdeskApiError.forbiddenError('User not active') ids = self.store_reset_password_token(doc, email, token_ttl, user['_id']) send_reset_password_email(doc, token_ttl) self.remove_private_data(doc) return ids
def initialize_reset_password(self, doc, email): token_ttl = app.config["RESET_PASSWORD_TOKEN_TIME_TO_LIVE"] user = superdesk.get_resource_service("users").find_one(req=None, email=email) if not user: logger.warning( "User password reset triggered with invalid email: %s" % email) raise SuperdeskApiError.badRequestError(_("Invalid email")) if not user.get("is_enabled", False): logger.warning( "User password reset triggered for an disabled user") raise SuperdeskApiError.forbiddenError(_("User not enabled")) if not user.get("is_active", False): logger.warning( "User password reset triggered for an inactive user") raise SuperdeskApiError.forbiddenError(_("User not active")) ids = self.store_reset_password_token(doc, email, token_ttl, user["_id"]) send_reset_password_email(doc, token_ttl) self.remove_private_data(doc) return ids
def initialize_reset_password(self, doc, email): user = app.data.find_one('users', req=None, email=email) if not user: logger.warning('User password reset triggered with invalid email: %s' % email) raise superdesk.SuperdeskError(status_code=201, message='Created') doc[app.config['DATE_CREATED']] = utcnow() doc[app.config['LAST_UPDATED']] = utcnow() doc['user'] = user['_id'] doc['token'] = get_random_string() ids = super().create([doc]) send_reset_password_email(doc) self.remove_private_data(doc) return ids
def initialize_reset_password(self, doc, email): token_ttl = app.config['RESET_PASSWORD_TOKEN_TIME_TO_LIVE'] user = superdesk.get_resource_service('users').find_one(req=None, email=email) if not user: logger.warning('User password reset triggered with invalid email: %s' % email) raise superdesk.SuperdeskError(status_code=400, message='Created') if not user.get('is_active', False): logger.warning('User password reset triggered for an inactive user') raise superdesk.SuperdeskError(status_code=403, message='Created') ids = self.store_reset_password_token(doc, email, token_ttl, user['_id']) send_reset_password_email(doc) self.remove_private_data(doc) return ids
def initialize_reset_password(self, doc, email): token_ttl = app.config['RESET_PASSWORD_TOKEN_TIME_TO_LIVE'] user = superdesk.get_resource_service('users').find_one(req=None, email=email) if not user: logger.warning('User password reset triggered with invalid email: %s' % email) raise SuperdeskApiError.badRequestError('Invalid email') if not user.get('is_enabled', False): logger.warning('User password reset triggered for an disabled user') raise SuperdeskApiError.forbiddenError('User not enabled') if not user.get('is_active', False): logger.warning('User password reset triggered for an inactive user') raise SuperdeskApiError.forbiddenError('User not active') ids = self.store_reset_password_token(doc, email, token_ttl, user['_id']) send_reset_password_email(doc) self.remove_private_data(doc) return ids
def initialize_reset_password(self, doc, email): token_ttl = app.config['RESET_PASSWORD_TOKEN_TIME_TO_LIVE'] user = superdesk.get_resource_service('users').find_one(req=None, email=email) if not user: logger.warning( 'User password reset triggered with invalid email: %s' % email) raise superdesk.SuperdeskError(status_code=400, message='Created') if not user.get('is_active', False): logger.warning( 'User password reset triggered for an inactive user') raise superdesk.SuperdeskError(status_code=403, message='Created') ids = self.store_reset_password_token(doc, email, token_ttl, user['_id']) send_reset_password_email(doc) self.remove_private_data(doc) return ids