Skip to content

Commit

Permalink
More review
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Dec 28, 2023
1 parent 556fc5c commit 49eb177
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse {
/** @property IDToken
@brief The ID token in the email link sign-in response.
*/
private var _idToken: String?
private(set) var idToken: String?

/** @property email
@brief The email returned by the IdP.
Expand All @@ -47,26 +47,20 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse {

// MARK: - AuthMFAResponse

var mfaPendingCredential: String? { return _mfaPendingCredential }

var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo }

var idToken: String? { return _idToken }

/** @property MFAPendingCredential
@brief An opaque string that functions as proof that the user has successfully passed the first
factor check.
*/
private var _mfaPendingCredential: String?
private(set) var mfaPendingCredential: String?

/** @property MFAInfo
@brief Info on which multi-factor authentication providers are enabled.
*/
private var _mfaInfo: [AuthProtoMFAEnrollment]?
private(set) var mfaInfo: [AuthProtoMFAEnrollment]?

func setFields(dictionary: [String: AnyHashable]) throws {
email = dictionary["email"] as? String
_idToken = dictionary["idToken"] as? String
idToken = dictionary["idToken"] as? String
isNewUser = dictionary["isNewUser"] as? Bool ?? false
refreshToken = dictionary["refreshToken"] as? String

Expand All @@ -80,8 +74,8 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse {
let enrollment = AuthProtoMFAEnrollment(dictionary: entry)
mfaInfo.append(enrollment)
}
_mfaInfo = mfaInfo
self.mfaInfo = mfaInfo
}
_mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse {
access token from Secure Token Service, depending on whether @c returnSecureToken is set
on the request.
*/
private var _idToken: String?
private(set) var idToken: String?

/** @property approximateExpirationDate
@brief The approximate expiration date of the access token.
Expand Down Expand Up @@ -203,15 +203,9 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse {

// MARK: - AuthMFAResponse

var mfaPendingCredential: String? { return _mfaPendingCredential }
private(set) var mfaPendingCredential: String?

var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo }

var idToken: String? { return _idToken }

private var _mfaPendingCredential: String?

private var _mfaInfo: [AuthProtoMFAEnrollment]?
private(set) var mfaInfo: [AuthProtoMFAEnrollment]?

func setFields(dictionary: [String: AnyHashable]) throws {
federatedID = dictionary["federatedId"] as? String
Expand All @@ -229,7 +223,7 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse {
fullName = dictionary["fullName"] as? String
nickName = dictionary["nickName"] as? String
displayName = dictionary["displayName"] as? String
_idToken = dictionary["idToken"] as? String
idToken = dictionary["idToken"] as? String
if let expiresIn = dictionary["expiresIn"] as? String {
approximateExpirationDate = Date(timeIntervalSinceNow: (expiresIn as NSString)
.doubleValue)
Expand Down Expand Up @@ -275,10 +269,10 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse {
pendingToken = dictionary["pendingToken"] as? String

if let mfaInfoDicts = dictionary["mfaInfo"] as? [[String: AnyHashable]] {
_mfaInfo = mfaInfoDicts.map {
mfaInfo = mfaInfoDicts.map {
AuthProtoMFAEnrollment(dictionary: $0)
}
}
_mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse {
access token from Secure Token Service, depending on whether @c returnSecureToken is set
on the request.
*/
private var _idToken: String?
private(set) var idToken: String?

/** @property approximateExpirationDate
@brief The approximate expiration date of the access token.
Expand All @@ -64,21 +64,15 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse {

// MARK: - AuthMFAResponse

var mfaPendingCredential: String? { return _mfaPendingCredential }
private(set) var mfaPendingCredential: String?

var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo }

var idToken: String? { return _idToken }

private var _mfaPendingCredential: String?

private var _mfaInfo: [AuthProtoMFAEnrollment]?
private(set) var mfaInfo: [AuthProtoMFAEnrollment]?

func setFields(dictionary: [String: AnyHashable]) throws {
localID = dictionary["localId"] as? String
email = dictionary["email"] as? String
displayName = dictionary["displayName"] as? String
_idToken = dictionary["idToken"] as? String
idToken = dictionary["idToken"] as? String
if let expiresIn = dictionary["expiresIn"] as? String {
approximateExpirationDate = Date(timeIntervalSinceNow: (expiresIn as NSString)
.doubleValue)
Expand All @@ -87,8 +81,8 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse {
photoURL = (dictionary["photoUrl"] as? String).flatMap { URL(string: $0) }

if let mfaInfo = dictionary["mfaInfo"] as? [[String: AnyHashable]] {
_mfaInfo = mfaInfo.map { AuthProtoMFAEnrollment(dictionary: $0) }
self.mfaInfo = mfaInfo.map { AuthProtoMFAEnrollment(dictionary: $0) }
}
_mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
mfaPendingCredential = dictionary["mfaPendingCredential"] as? String
}
}

0 comments on commit 49eb177

Please sign in to comment.