Преглед изворни кода

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 пре 1 месец
родитељ
комит
872f67f5ea
2 измењених фајлова са 16 додато и 20 уклоњено
  1. 3 2
      meetings_app/Auth/GoogleOAuthService.swift
  2. 13 18
      meetings_app/ViewController.swift

+ 3 - 2
meetings_app/Auth/GoogleOAuthService.swift

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

+ 13 - 18
meetings_app/ViewController.swift

@@ -6642,25 +6642,20 @@ private extension ViewController {
6642 6642
     }
6643 6643
 
6644 6644
     private func performGoogleSignOut() {
6645
-        Task { [weak self] in
6646
-            guard let self else { return }
6647
-            do {
6648
-                try await self.googleOAuth.signOutAndRevoke()
6649
-                await MainActor.run {
6650
-                    self.applyGoogleProfile(nil)
6651
-                    self.updateGoogleAuthButtonTitle()
6652
-                    self.pageCache[.joinMeetings] = nil
6653
-                    self.pageCache[.photo] = nil
6654
-                    self.pageCache[.video] = nil
6655
-                    self.pageCache[.settings] = nil
6656
-                    self.showSidebarPage(self.selectedSidebarPage)
6657
-                }
6658
-                await self.loadSchedule()
6659
-            } catch {
6660
-                await MainActor.run {
6661
-                    self.showSimpleError("Couldn’t logout Google account.", error: error)
6662
-                }
6645
+        do {
6646
+            try googleOAuth.signOut()
6647
+            applyGoogleProfile(nil)
6648
+            updateGoogleAuthButtonTitle()
6649
+            pageCache[.joinMeetings] = nil
6650
+            pageCache[.photo] = nil
6651
+            pageCache[.video] = nil
6652
+            pageCache[.settings] = nil
6653
+            showSidebarPage(selectedSidebarPage)
6654
+            Task { [weak self] in
6655
+                await self?.loadSchedule()
6663 6656
             }
6657
+        } catch {
6658
+            showSimpleError("Couldn’t logout Google account.", error: error)
6664 6659
         }
6665 6660
     }
6666 6661