Skip to content

Commit

Permalink
Logic update
Browse files Browse the repository at this point in the history
  • Loading branch information
borut-t committed Sep 12, 2023
1 parent 463bc35 commit 65ede85
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Sources/Apple/AppleAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,23 @@ extension AppleAuthenticator: ASAuthorizationControllerDelegate {
return .init(address: $0, isPrivate: isEmailPrivate, isVerified: isEmailVerified)
}

// do not continue if `email` is missing
guard let email else {
rejectSignIn(with: .missingEmail)
return
}

// do not continue if `expiresAt` is missing
guard let expiresAt = jwt?.expiresAt else {
rejectSignIn(with: .missingExpiration)
return
}

let response = Response(userId: credential.user,
token: identityTokenString,
name: credential.displayName,
email: email,
expiresAt: jwt?.expiresAt)
expiresAt: expiresAt)

processingPromise?.resolve(with: response)
case _:
Expand All @@ -139,6 +151,8 @@ public extension AppleAuthenticator {
case invalidIdentityToken
case unhandledAuthorization
case credentialsRevoked
case missingExpiration
case missingEmail
}
}

Expand Down

0 comments on commit 65ede85

Please sign in to comment.