Skip to content

Commit 01b087e

Browse files
committed
fixed some linting issues
1 parent 0c15c6b commit 01b087e

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

project/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from dotenv import load_dotenv
33
import os
44

5+
56
def create_app():
67
load_dotenv()
78
app = Flask(__name__)
@@ -16,4 +17,4 @@ def create_app():
1617
from .main import main as main_blueprint
1718
app.register_blueprint(main_blueprint)
1819

19-
return app
20+
return app

project/auth.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,59 @@
44
import requests
55
import os
66

7-
client_id=os.getenv('GAMMA_CLIENT_ID', '')
8-
client_secret=os.getenv('GAMMA_CLIENT_SECRET', '')
9-
redirect_uri=os.getenv('GAMMA_REDIRECT_URI', 'http://localhost:5000/api/auth/callbacks/gamma')
10-
auth_uri=os.getenv('GAMMA_AUTH_URL', 'https://auth.chalmers.it/oauth2/authorize')
11-
token_uri=os.getenv('GAMMA_TOKEN_URL', 'https://auth.chalmers.it/oauth2/token')
12-
user_info_uri=os.getenv('GAMMA_USER_INFO_URL', 'https://auth.chalmers.it/oauth2/userinfo')
7+
client_id = os.getenv('GAMMA_CLIENT_ID', '')
8+
client_secret = os.getenv('GAMMA_CLIENT_SECRET', '')
9+
redirect_uri = os.getenv('GAMMA_REDIRECT_URI', 'http://localhost:5000/api/auth/callbacks/gamma')
10+
auth_uri = os.getenv('GAMMA_AUTH_URL', 'https://auth.chalmers.it/oauth2/authorize')
11+
token_uri = os.getenv('GAMMA_TOKEN_URL', 'https://auth.chalmers.it/oauth2/token')
12+
user_info_uri = os.getenv('GAMMA_USER_INFO_URL', 'https://auth.chalmers.it/oauth2/userinfo')
1313

1414
auth = Blueprint('auth', __name__)
1515

16+
1617
@auth.route('/login')
1718
def login():
1819
return render_template('login.html')
1920

21+
2022
@auth.route('/authorize')
2123
def authorize():
2224
# Generate and store state parameter for CSRF protection
2325
state = secrets.token_urlsafe(32)
2426
session['oauth2_state'] = state
25-
2627
qs = {
2728
'response_type': 'code',
2829
'client_id': client_id,
29-
'scope': 'openid', #profile
30+
'scope': 'openid', # profile
3031
'redirect_uri': redirect_uri,
31-
'state':state,
32+
'state': state,
3233
}
33-
3434
return redirect(f"{auth_uri}?{urlencode(qs)}")
3535

36+
3637
@auth.route('/api/auth/callbacks/gamma')
3738
def callback():
3839
args_dict = dict(request.args)
3940
print(args_dict)
40-
41+
4142
if 'code' not in args_dict:
4243
return "Error: Missing authorization code parameter", 400
43-
44+
4445
if 'state' not in args_dict:
4546
return "Error: Missing state parameter", 400
46-
47+
4748
received_state = args_dict['state']
4849
stored_state = session.get('oauth2_state')
49-
50+
5051
if not stored_state or received_state != stored_state:
5152
return "Error: Invalid state parameter", 400
5253

5354
session.pop('oauth2_state', None)
54-
55+
5556
code = args_dict['code']
56-
return code
57+
return render_template('profile.html')
58+
5759

5860
@auth.route('/logout')
5961
def logout():
60-
return render_template('logout.html')
62+
return render_template('logout.html')

project/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
main = Blueprint('main', __name__)
44

5+
56
@main.route('/')
67
def index():
78
return render_template('index.html')
89

10+
911
@main.route('/profile')
1012
def profile():
11-
return render_template('profile.html')
13+
return render_template('profile.html')

project/templates/profile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
{% block content %}
44
<h1 class="title">
5-
Welcome, Anthony!
5+
Welcome, digIT!
66
</h1>
77
{% endblock %}

0 commit comments

Comments
 (0)