Esempio n. 1
0
	def post(self):
		""" Authorise user and provide access token"""
		username = request.json.get('username')
		password = request.json.get('password')
		user = User.find_by_username(username)
		if not user:
			return error_response('Username does not exist', 401)
		if not user.check_password(password):
			return error_response('Incorrect password', 401)
		access_token = create_access_token(identity=user.id)
		return make_response(jsonify(access_token = access_token), 201)
Esempio n. 2
0
 def get_user_id(self, username):
     with app.app_context():
         u = User.find_by_username(username)
         return u.id