From 9e9b3fad8581339b5766ddba13db182d76856a84 Mon Sep 17 00:00:00 2001 From: Rujin Devkota Date: Sat, 21 Dec 2024 19:42:33 +0545 Subject: [PATCH] fix(auth): resolve login issue with username and reg number --- VITTY/GoogleService-Info.plist | 36 +++++++++++++++++++ VITTY/VITTY.xcodeproj/project.pbxproj | 8 +++-- .../VITTY/Auth/ViewModels/AuthViewModel.swift | 34 +++++++++--------- VITTY/VITTY/Username/Views/UsernameView.swift | 9 +++-- 4 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 VITTY/GoogleService-Info.plist diff --git a/VITTY/GoogleService-Info.plist b/VITTY/GoogleService-Info.plist new file mode 100644 index 0000000..fed3ea3 --- /dev/null +++ b/VITTY/GoogleService-Info.plist @@ -0,0 +1,36 @@ + + + + + CLIENT_ID + 272763363329-i8n51oo9m30h9it7qq9ufmd0lahnmm63.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.272763363329-i8n51oo9m30h9it7qq9ufmd0lahnmm63 + ANDROID_CLIENT_ID + 272763363329-aa1tp2s4hogqcja3vn8jf19itn9s8r9o.apps.googleusercontent.com + API_KEY + AIzaSyCJYYDMdzQiNiY0pxqbrglEw85BSlGgHBc + GCM_SENDER_ID + 272763363329 + PLIST_VERSION + 1 + BUNDLE_ID + com.gdscvit.vittyios + PROJECT_ID + vitty-dscvit + STORAGE_BUCKET + vitty-dscvit.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:272763363329:ios:3b020b67f7527e83e2e000 + + \ No newline at end of file diff --git a/VITTY/VITTY.xcodeproj/project.pbxproj b/VITTY/VITTY.xcodeproj/project.pbxproj index e058d3e..1aedcbc 100644 --- a/VITTY/VITTY.xcodeproj/project.pbxproj +++ b/VITTY/VITTY.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 317715DE279F1431009A532E /* IndexedCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317715DD279F1431009A532E /* IndexedCollection.swift */; }; 317EE1992775D3C6008AEB31 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317EE1982775D3C6008AEB31 /* SettingsView.swift */; }; 31A3BF4027D09AF300B6BB97 /* Date+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A3BF3F27D09AF300B6BB97 /* Date+Extension.swift */; }; + 4B76033B2D168E3F002DA484 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4B76033A2D168E3F002DA484 /* GoogleService-Info.plist */; }; 520BA6432B47FFF900124850 /* SuggestedFriendsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520BA6422B47FFF900124850 /* SuggestedFriendsViewModel.swift */; }; 520BA6452B48013200124850 /* SuggestedFriendsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520BA6442B48013200124850 /* SuggestedFriendsView.swift */; }; 520BA6482B4802EE00124850 /* AddFriendCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520BA6472B4802EE00124850 /* AddFriendCard.swift */; }; @@ -127,6 +128,7 @@ 317715DD279F1431009A532E /* IndexedCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndexedCollection.swift; sourceTree = ""; }; 317EE1982775D3C6008AEB31 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 31A3BF3F27D09AF300B6BB97 /* Date+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extension.swift"; sourceTree = ""; }; + 4B76033A2D168E3F002DA484 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 520BA6422B47FFF900124850 /* SuggestedFriendsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedFriendsViewModel.swift; sourceTree = ""; }; 520BA6442B48013200124850 /* SuggestedFriendsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedFriendsView.swift; sourceTree = ""; }; 520BA6472B4802EE00124850 /* AddFriendCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFriendCard.swift; sourceTree = ""; }; @@ -266,6 +268,7 @@ isa = PBXGroup; children = ( 52EE849D2CB9CD1F00CD864C /* GoogleService-Info.plist */, + 4B76033A2D168E3F002DA484 /* GoogleService-Info.plist */, 5251A7FF2B46E3C000D44CFE /* .swift-format */, 314A408E27383BEC0058082F /* VITTYApp.swift */, 314A409027383BEC0058082F /* ContentView.swift */, @@ -760,6 +763,7 @@ 31128CFA2772F57E0084C9EA /* Poppins-SemiBoldItalic.ttf in Resources */, 31128CFC2772F57E0084C9EA /* Poppins-Regular.ttf in Resources */, 52EE849E2CB9CD1F00CD864C /* GoogleService-Info.plist in Resources */, + 4B76033B2D168E3F002DA484 /* GoogleService-Info.plist in Resources */, 314A409627383BEE0058082F /* Preview Assets.xcassets in Resources */, 314A409327383BEE0058082F /* Assets.xcassets in Resources */, ); @@ -952,7 +956,7 @@ CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = "\"VITTY/Preview Content\""; - DEVELOPMENT_TEAM = 2TS98F9X52; + DEVELOPMENT_TEAM = C7RX29D33F; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VITTY/Info.plist; @@ -992,7 +996,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"VITTY/Preview Content\""; - DEVELOPMENT_TEAM = 2TS98F9X52; + DEVELOPMENT_TEAM = C7RX29D33F; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VITTY/Info.plist; diff --git a/VITTY/VITTY/Auth/ViewModels/AuthViewModel.swift b/VITTY/VITTY/Auth/ViewModels/AuthViewModel.swift index d386862..a5c2336 100644 --- a/VITTY/VITTY/Auth/ViewModels/AuthViewModel.swift +++ b/VITTY/VITTY/Auth/ViewModels/AuthViewModel.swift @@ -58,23 +58,23 @@ class AuthViewModel: NSObject, ASAuthorizationControllerDelegate { } -// private func signInServer(username: String, regNo: String) async { -// logger.info("Signing into server...") -// do { -// self.loggedInBackendUser = try await AuthAPIService.shared -// .signInUser( -// with: AuthRequestBody( -// uuid: loggedInFirebaseUser?.uid ?? "", -// reg_no: regNo, -// username: username -// ) -// ) -// } -// catch { -// logger.error("Signing into server error: \(error)") -// } -// logger.info("Signed into server") -// } + func signInServer(username: String, regNo: String) async { + logger.info("Signing into server...") + do { + self.loggedInBackendUser = try await AuthAPIService.shared + .signInUser( + with: AuthRequestBody( + uuid: loggedInFirebaseUser?.uid ?? "", + reg_no: regNo, + username: username + ) + ) + } + catch { + logger.error("Signing into server error: \(error)") + } + logger.info("Signed into server") + } private func firebaseUserAuthUpdate(with auth: Auth, user: User?) { logger.info("Firebase User Auth State Updated") diff --git a/VITTY/VITTY/Username/Views/UsernameView.swift b/VITTY/VITTY/Username/Views/UsernameView.swift index 5b71d44..719017b 100644 --- a/VITTY/VITTY/Username/Views/UsernameView.swift +++ b/VITTY/VITTY/Username/Views/UsernameView.swift @@ -82,11 +82,10 @@ struct UsernameView: View { Spacer() Button(action: { Task { - // TODO: Important - -// isLoading = true -// await authViewModel.signInServer(username: username, regNo: regNo) -// isLoading = false + +isLoading = true + await authViewModel.signInServer(username: username, regNo: regNo) + isLoading = false } }) { if isLoading {