Quellcode durchsuchen

callback invaild 값 오류 메시지 추가

hoparkgo9ma vor 7 Jahren
Ursprung
Commit
64be12b4ee
3 geänderte Dateien mit 20 neuen und 8 gelöschten Zeilen
  1. 14 8
      app.py
  2. 3 0
      language/en-US.json
  3. 3 0
      language/ko-KR.json

+ 14 - 8
app.py

@@ -2819,9 +2819,9 @@ def login_oauth(platform = None, func = None):
 
     if func == 'init':
         if oauth_data['client_id'] == '' or oauth_data['client_secret'] == '':
-            return easy_minify(flask.render_template(skin_check(), imp = [load_lang('login'), wiki_set(), custom(), other2([0, 0])], data =  load_lang('oauth_disabled'), menu = [['user', load_lang('user')]]))
+            return easy_minify(flask.render_template(skin_check(), imp = [load_lang('login'), wiki_set(), custom(), other2([0, 0])], data = load_lang('oauth_disabled'), menu = [['user', load_lang('user')]]))
         elif publish_url == 'https://':
-            return easy_minify(flask.render_template(skin_check(), imp = [load_lang('login'), wiki_set(), custom(), other2([0, 0])], data =  load_lang('oauth_settings_not_found'), menu = [['user', load_lang('user')]]))
+            return easy_minify(flask.render_template(skin_check(), imp = [load_lang('login'), wiki_set(), custom(), other2([0, 0])], data = load_lang('oauth_settings_not_found'), menu = [['user', load_lang('user')]]))
 
         referrer_re = re.compile(r'(?P<host>^(https?):\/\/([^\/]+))\/(?P<refer>[^\/?]+)')
         if flask.request.referrer != None:
@@ -2833,18 +2833,24 @@ def login_oauth(platform = None, func = None):
         else:
             return redirect('/')
         flask.session['refer'] = flask.request.referrer
-        
+
         if platform == 'naver':
             return redirect(api_url['redirect']+'?response_type=code&client_id={}&redirect_uri={}&state={}'.format(data['client_id'], data['redirect_uri'], data['state']))
         elif platform == 'facebook':
             return redirect(api_url['redirect']+'?client_id={}&redirect_uri={}&state={}'.format(data['client_id'], data['redirect_uri'], data['state']))
 
     elif func == 'callback':
-        try:
-            code = flask.request.args.get('code')
-            state = flask.request.args.get('state')
-        except:
-            return '잘못된 callback입니다.'
+        code = flask.request.args.get('code')
+        state = flask.request.args.get('state')
+        if code == None or state == None:
+            return easy_minify(flask.render_template(skin_check(), imp = [load_lang('inter_error'), wiki_set(), custom(), other2([0, 0])], data = 
+            '''<p>''' + load_lang('inter_error_detail') + '''</p>
+            <hr>
+            <code>ie_wrong_callback</code>
+            <p>''' + load_lang('ie_wrong_callback') + '''</p>
+            '''
+            , menu = [['user', load_lang('user')]]))
+
         if platform == 'naver':
             token_access = api_url['token']+'?grant_type=authorization_code&client_id={}&client_secret={}&code={}&state={}'.format(data['client_id'], data['client_secret'], code, state)
             token_result = urllib.request.urlopen(token_access).read().decode('utf-8')

+ 3 - 0
language/en-US.json

@@ -105,6 +105,9 @@
     "password" : "password",
     "confirm" : "confirm",
     "connection" : "Connection",
+    "inter_error" : "Inter Error!",
+    "inter_error_detail" : "An internal error occurred during the verification process. Please check the details below.",
+    "ie_wrong_callback" : "The SNS service provider has sent an invalid value to the callback route. <a href=\"/login\">Try login again.</a>",
     "oauth_conn_done" : " connected",
     "oauth_conn_not" : " not found",
     "oauth_conn_new" : "Connect..",

+ 3 - 0
language/ko-KR.json

@@ -97,6 +97,9 @@
     "password" : "암호",
     "confirm" : "확인",
     "connection" : "연결",
+    "inter_error" : "내부 오류!",
+    "inter_error_detail" : "인증 절차를 진행하는 도중 내부 오류가 발생했습니다. 아래에서 자세한 사항을 확인하세요.",
+    "ie_wrong_callback" : "SNS 서비스 제공자가 callback 라우트에 잘못된 값을 전송했습니다. <a href=\"/login\">다시 시도하세요.</a>",
     "oauth_conn_done" : "됨",
     "oauth_conn_not" : "없음",
     "oauth_conn_new" : "연결하기",