Skip to content

Commit

Permalink
Fix: Social auth banner (#558)
Browse files Browse the repository at this point in the history
* fix: fix social auth banner

Co-Authored-By: Anton Yarmolenko <[email protected]>

* fix: fixed test

* chore: address feedback

---------

Co-authored-by: Anton Yarmolenko <[email protected]>
  • Loading branch information
rnr and rnr authored Jan 14, 2025
1 parent 7e67397 commit 315433f
Show file tree
Hide file tree
Showing 22 changed files with 201 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import OEXFoundation
public enum AuthMethod: Equatable {
case password
case SSO
case socailAuth(SocialAuthMethod)
case socialAuth(SocialAuthMethod)

public var analyticsValue: String {
switch self {
case .password:
"password"
case .SSO:
"SSO"
case .socailAuth(let socialAuthMethod):
case .socialAuth(let socialAuthMethod):
socialAuthMethod.rawValue
}
}
Expand Down
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 .socialAuth(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 .socialAuth(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 .socialAuth(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
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ enum SocialAuthDetails {
var authMethod: AuthMethod {
switch self {
case .apple:
.socailAuth(.apple)
.socialAuth(.apple)
case .facebook:
.socailAuth(.facebook)
.socialAuth(.facebook)
case .google:
.socailAuth(.google)
.socialAuth(.google)
case .microsoft:
.socailAuth(.microsoft)
.socialAuth(.microsoft)
}
}

Expand Down
Loading

0 comments on commit 315433f

Please sign in to comment.