chenbiao 3 лет назад
Родитель
Сommit
31c3183346

+ 5 - 5
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAuthServiceImpl.java

@@ -223,9 +223,8 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
                     while (sb.length() < 6) {
                         sb.insert(0, 0);
                     }
-                    four(codeVerifier, Location, code, username);
-            }
-            if (Location.contains("com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback?")) {
+                    return four(codeVerifier, Location, code, username);
+            } else if (Location.contains("com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback?")) {
                 return getAccessToken(codeVerifier, Location, username);
             } else {
                 log.info("Login callback failed.");
@@ -234,7 +233,7 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
         return null;
     }
 
-    private void four(String codeVerifier, String location, long code, String username){
+    private String four(String codeVerifier, String location, long code, String username){
         String url = "https://auth0.openai.com" + location;
         Map<String, String> paramMap = HttpUtil.decodeParamMap(url, IoKit.Charsets.UTF_8.getCharset());
 
@@ -255,9 +254,10 @@ public class ChatGptAuthServiceImpl implements ChatGptAuthService {
         if (execute.getStatus() == 302) {
             String Location = execute.header("Location");
             if (Location.contains("/authorize/resume?")) {
-                three(codeVerifier, Location, url, username);
+                return three(codeVerifier, Location, url, username);
             } else {
                 log.info("Login failed.");
+                throw BusinessRuntimeException.getInstance("four Login failed.");
             }
         } else if (execute.getStatus() == 400) {
             throw BusinessRuntimeException.getInstance("wrong MFA code.");