Skip to content
Snippets Groups Projects
Commit 499f2156 authored by Jonas Leder's avatar Jonas Leder
Browse files

fixed login

parent f8235760
Branches
Tags 1.7.6 1.7.7
No related merge requests found
Pipeline #84 skipped
...@@ -253,8 +253,8 @@ def authorizeGoogle(): ...@@ -253,8 +253,8 @@ def authorizeGoogle():
userID = r.text.split('"id": "')[1].split('"')[0] userID = r.text.split('"id": "')[1].split('"')[0]
name = r.text.split('"name": "')[1].split('"')[0] name = r.text.split('"name": "')[1].split('"')[0]
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))
return resp return resp
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
def authorizeGithub(): def authorizeGithub():
try:
code = request.args.get("code") code = request.args.get("code")
url = "https://github.com/login/oauth/access_token" #The baseurl url = "https://github.com/login/oauth/access_token" #The baseurl
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
resp.dumps('username', s.dumps(username)) resp.set_cookie('username', s.dumps(username))
return resp return resp
except:
return "Authentication failed"
@app.route('/user/logout') @app.route('/user/logout')
def logout(): def logout():
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment