File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1313# function is used to actually generate the token
1414@app .route ('/login' , methods = ['POST' ])
1515def login ():
16- username = request .json .get ('username' , None )
17- password = request .json .get ('password' , None )
18- if username != 'test' or password != 'test' :
19- return jsonify ({"msg" : "Bad username or password" }), 401
16+ if not request .is_json :
17+ return jsonify ({"msg" : "Missing auth" }), 401
18+ params = request .get_json ()
19+ if 'username' in params and 'password' in params :
20+ if params ['username' ] != 'test' or params ['password' ] != 'test' :
21+ return jsonify ({"msg" : "Bad username or password" }), 401
22+ else :
23+ return jsonify ({"msg" : "Missing auth parameters" }), 401
2024
2125 # Identity can be any data that is json serializable
22- ret = {'access_token' : create_access_token (identity = username )}
26+ ret = {'access_token' : create_access_token (identity = params [ ' username' ] )}
2327 return jsonify (ret ), 200
2428
29+
2530
2631# Protect a view with jwt_required, which requires a valid access token
2732# in the request to access.
You can’t perform that action at this time.
0 commit comments