Skip to content

Commit

Permalink
fix: fix social auth banner
Browse files Browse the repository at this point in the history
Co-Authored-By: Anton Yarmolenko <[email protected]>
  • Loading branch information
rnr and rnr committed Jan 9, 2025
1 parent 7e67397 commit e375c0c
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(username: username, password: password)
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: .password)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, authMethod: nil)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: nil)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
failure(error)
Expand All @@ -101,7 +101,7 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(ssoToken: "")
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: .password)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, authMethod: nil)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: nil)
} catch let error {
failure(error)
}
Expand Down Expand Up @@ -132,14 +132,11 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(externalToken: externalToken, backend: backend)
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: authMethod)
var socialAuthMethod: String?
if case AuthMethod.socailAuth(let method) = authMethod {
socialAuthMethod = method.rawValue
var postLoginData: PostLoginData?
if case .socailAuth(let socialMethod) = authMethod {
postLoginData = PostLoginData(authMethod: socialMethod.rawValue, showSocialRegisterBanner: false)
}
router.showMainOrWhatsNewScreen(
sourceScreen: sourceScreen,
authMethod: socialAuthMethod
)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: postLoginData)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
failure(error, authMethod: authMethod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ public final class SignUpViewModel: ObservableObject {
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.registrationSuccess(method: authMetod.analyticsValue)
isShowProgress = false
var socialAuthMethod: String?
if case AuthMethod.socailAuth(let method) = authMethod {
socialAuthMethod = method.rawValue
var postLoginData: PostLoginData?
if case .socailAuth(let socialMethod) = authMethod {
postLoginData = PostLoginData(authMethod: socialMethod.rawValue, showSocialRegisterBanner: false)
}
router.showMainOrWhatsNewScreen(
sourceScreen: sourceScreen,
authMethod: socialAuthMethod
)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: postLoginData)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch let error {
isShowProgress = false
Expand Down Expand Up @@ -204,21 +201,12 @@ public final class SignUpViewModel: ObservableObject {
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: authMethod)
isShowProgress = false
var socialAuthMethod: String?
if case AuthMethod.socailAuth(let method) = authMethod {
socialAuthMethod = method.rawValue
var postLoginData: PostLoginData?
if case .socailAuth(let socialMethod) = authMethod {
postLoginData = PostLoginData(authMethod: socialMethod.rawValue, showSocialRegisterBanner: true)
}
router.showMainOrWhatsNewScreen(
sourceScreen: sourceScreen,
authMethod: socialAuthMethod
)
NotificationCenter.default.post(
name: .userAuthorized,
object: [
"authMethod": authMethod,
"showSocialRegisterBanner": true
]
)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: postLoginData)
NotificationCenter.default.post(name: .userAuthorized, object: nil)
} catch {
update(fullName: response.name, email: response.email)
self.externalToken = response.token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class SSOWebViewModel: ObservableObject {
let user = try await interactor.login(ssoToken: "\(payload).\(signature)")
analytics.identify(id: "\(user.id)", username: user.username, email: user.email)
analytics.userLogin(method: .SSO)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, authMethod: nil)
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen, postLoginData: nil)
} catch let error {
failure(error, authMethod: .SSO)
}
Expand Down
Loading

0 comments on commit e375c0c

Please sign in to comment.