def authenticate(username, password): print username print password user = UserModel.find(_username=username) print user if user is not None: if user.verify_password(password): return user
def post(self): print request.json['token'] token = PasswordToken.find(_token=request.json['token']) if token is not None: user = User.find(id=token.user_id) user.password = request.json['password'] return '', 200 abort(400)
def get(self, id): user = User.find(id=id) user.password = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(32)) user.save() token = PasswordToken() token._token = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(32)) token.user_id = user.id token.save() msg = Message() msg.html = render_template('force_email.html', token=token._token) msg.recipients = [user.email] msg.subject = 'Action Required: CCMA Password Reset' mail.send(msg) return '', 200
def get(self, id): user = User.find(id=id) user.password = ''.join( random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(32)) user.save() token = PasswordToken() token._token = ''.join( random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(32)) token.user_id = user.id token.save() msg = Message() msg.html = render_template('force_email.html', token=token._token) msg.recipients = [user.email] msg.subject = 'Action Required: CCMA Password Reset' mail.send(msg) return '', 200
def load_user(payload): user = UserModel.find(id=payload['user_id']) return user