Sfoglia il codice sorgente

Reduce repeated Google consent prompts and restore local-only logout.

Stop forcing OAuth consent on each sign-in by reusing previously granted scopes, and revert logout to clearing local tokens without remote revoke so returning users can reconnect more smoothly.

Made-with: Cursor
huzaifahayat12 3 mesi fa
parent
commit
872f67f5ea

+ 3 - 2
meetings_app/Auth/GoogleOAuthService.swift

@@ -144,11 +144,12 @@ final class GoogleOAuthService: NSObject {
             URLQueryItem(name: "redirect_uri", value: redirectURI),
             URLQueryItem(name: "response_type", value: "code"),
             URLQueryItem(name: "scope", value: scopes.joined(separator: " ")),
+            // Reuse already granted scopes so users are not repeatedly asked.
+            URLQueryItem(name: "include_granted_scopes", value: "true"),
             URLQueryItem(name: "state", value: state),
             URLQueryItem(name: "code_challenge", value: codeChallenge),
             URLQueryItem(name: "code_challenge_method", value: "S256"),
-            URLQueryItem(name: "access_type", value: "offline"),
-            URLQueryItem(name: "prompt", value: "consent")
+            URLQueryItem(name: "access_type", value: "offline")
         ]
 
         guard let authURL = components.url else { throw GoogleOAuthError.invalidCallbackURL }

+ 13 - 18
meetings_app/ViewController.swift

@@ -6642,25 +6642,20 @@ private extension ViewController {
     }
 
     private func performGoogleSignOut() {
-        Task { [weak self] in
-            guard let self else { return }
-            do {
-                try await self.googleOAuth.signOutAndRevoke()
-                await MainActor.run {
-                    self.applyGoogleProfile(nil)
-                    self.updateGoogleAuthButtonTitle()
-                    self.pageCache[.joinMeetings] = nil
-                    self.pageCache[.photo] = nil
-                    self.pageCache[.video] = nil
-                    self.pageCache[.settings] = nil
-                    self.showSidebarPage(self.selectedSidebarPage)
-                }
-                await self.loadSchedule()
-            } catch {
-                await MainActor.run {
-                    self.showSimpleError("Couldn’t logout Google account.", error: error)
-                }
+        do {
+            try googleOAuth.signOut()
+            applyGoogleProfile(nil)
+            updateGoogleAuthButtonTitle()
+            pageCache[.joinMeetings] = nil
+            pageCache[.photo] = nil
+            pageCache[.video] = nil
+            pageCache[.settings] = nil
+            showSidebarPage(selectedSidebarPage)
+            Task { [weak self] in
+                await self?.loadSchedule()
             }
+        } catch {
+            showSimpleError("Couldn’t logout Google account.", error: error)
         }
     }