resp=make_response(redirect('/'))#redirect the user at the end back to the main page
resp=make_response(redirect('/'))#redirect the user at the end back to the main page
resp.dumps('userID',s.sign("google_"+userID))#set the cookies with username and userid
resp.set_cookie('userID',s.dumps("google_"+userID))#set the cookies with username and userid
resp.dumps('username',s.sign(name))
resp.set_cookie('username',s.dumps(name))
returnresp
returnresp
except:
except:
return"Authentication failed"
return"Authentication failed"
...
@@ -262,6 +262,7 @@ def authorizeGoogle():
...
@@ -262,6 +262,7 @@ def authorizeGoogle():
@app.route('/user/github-callback')#Github redirects to this link after the user authenticated. Then we use the Token we get from github and request via the github api the username and the userid
@app.route('/user/github-callback')#Github redirects to this link after the user authenticated. Then we use the Token we get from github and request via the github api the username and the userid
params={'client_id':GITHUB_CLIENT_ID,'client_secret':GITHUB_CLIENT_SECRET,'code':code}#As paramtere we send the client id and the client secret which we get from github when registering an application and the user code from before
params={'client_id':GITHUB_CLIENT_ID,'client_secret':GITHUB_CLIENT_SECRET,'code':code}#As paramtere we send the client id and the client secret which we get from github when registering an application and the user code from before
...
@@ -273,9 +274,11 @@ def authorizeGithub():
...
@@ -273,9 +274,11 @@ def authorizeGithub():
username=str(json.loads(githubResponse)['login'])
username=str(json.loads(githubResponse)['login'])
resp=make_response(redirect('/'))#redirect the user at the end back to the main page
resp=make_response(redirect('/'))#redirect the user at the end back to the main page
resp.dumps('userID',s.dumps("github_"+userID))#set the cookies with username and userid
resp.set_cookie('userID',s.dumps("github_"+userID))#set the cookies with username and userid