def do_cli(manager, options, session=None): if hasattr(options, 'user'): options.user = options.user.lower() if options.action == 'passwd': user = user_exist(name=options.user, session=session) if not user: console('User %s does not exist' % options.user) return try: change_password(user_name=user.name, password=options.password, session=session) except WeakPassword as e: console(e.value) return console('Updated password for user %s' % options.user) if options.action == 'gentoken': user = user_exist(name=options.user, session=session) if not user: console('User %s does not exist' % options.user) return user = generate_token(user_name=user.name, session=session) console('Generated new token for user %s' % user.name) console('Token %s' % user.token)
def put(self, session=None): """ Change user password """ user = current_user data = request.json try: change_password(username=user.name, password=data.get('password'), session=session) except WeakPassword as e: raise BadRequest(e.value) return success_response('Successfully changed user password')
def put(self, session=None): """ Change user password """ user = current_user data = request.json try: change_password(username=user.name, password=data.get('password'), session=session) except WeakPassword as e: return {'status': 'error', 'message': e.value}, 500 return {'status': 'success', 'message': 'Successfully changed user password'}
def put(self, session=None): """ Change user password """ user = current_user data = request.json try: change_password(user_name=user.name, password=data.get('password'), session=session) except WeakPassword as e: return {'status': 'error', 'message': e.value}, 500 return {'status': 'success', 'message': 'Successfully changed user password'}
def do_cli(manager, options, session=None): if options.action == 'passwd': try: change_password(password=options.password, session=session) except WeakPassword as e: console(e.value) return console('Updated password') if options.action == 'gentoken': token = generate_token(session=session) console('Generated new token %s' % token) if options.action == 'showtoken': user = get_user() console('Token: %s' % user.token)