Exemplo n.º 1
0
	def post(self):
		username = get_jwt_identity()
		user = User.find_by_username(username)

		if user is None:
			report_error_and_abort(401, "refresh", "Login refresh failed")
		
		user.access_token = create_access_token(identity=user.username, fresh=False)
		TokenRegistry.add_token(user.access_token)
		return user, 200
Exemplo n.º 2
0
	def post(self, email, password, **kwargs):
		user = User.find_by_email(email)

		if user is None:
		   report_error_and_abort(401, "login", "Login failed") 

		if not user.confirmed:
			report_error_and_abort(401, "login", "Login failed")

		if not user.check_password(password):
			report_error_and_abort(401, "login", "Login failed")
		
		user.access_token = create_access_token(identity=user.username, fresh=True)
		TokenRegistry.add_token(user.access_token)
		return user, 200