From 7fce49ffc2a2b11b4efe9f38c36dceddb7bbce0d Mon Sep 17 00:00:00 2001 From: letsjo Date: Wed, 5 Apr 2023 18:33:58 +0900 Subject: [PATCH] =?UTF-8?q?[#3]=20Feat:=20=EC=A7=88=EB=AC=B8=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=ED=8C=90=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=EC=97=90=20=EB=94=B0=EB=9D=BC=20View=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 로그인할 경우에만 질문 input 창이 보일 수 있도록 처리함 --- app.py | 18 ++++++++++++++++-- templates/index.html | 39 +++------------------------------------ 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/app.py b/app.py index a2c1aac..c1c0fd1 100644 --- a/app.py +++ b/app.py @@ -103,8 +103,22 @@ def api_join(): @app.route('/detail') -def detailPage(): - return render_template('detail.html') +def detail(): + if 'Authorization' in session: + token_receive = session['Authorization'] + try: + payload = jwt.decode(token_receive, SECRET_KEY, + algorithms=['HS256']) + user_info = db.user.find_one({"id": payload['id']}) + return render_template('detail.html', isLogin=True, nickname=user_info["nick"]) + except jwt.ExpiredSignatureError: + session.pop('Authorization', None) + return render_template('detail.html', isLogin=False, alert="로그인 시간이 만료되었습니다. 다시 로그인 해주세요.") + except jwt.exceptions.DecodeError: + session.pop('Authorization', None) + return render_template('detail.html', isLogin=False, alert="로그인 정보가 존재하지 않아 로그아웃 되었습니다.") + else: + return render_template('detail.html') @app.route('/logout') diff --git a/templates/index.html b/templates/index.html index 377ba69..d7dcab0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,13 +11,15 @@ {%block content %}
+ {% if isLogin == True %}
+ placeholder="{{nickname}} 님 무엇이 궁금하신가요?">
+ {% endif %}
@@ -28,41 +30,6 @@

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

2023. 04. 04

-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-
-
-

답변대기중

-

스택 큐 알고리즘에 대해서 알려줄 수 있나요?

-

2023. 04. 04

-