mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-06-07 04:55:18 +00:00
COVIDSafe code from version 2.4 (#47)
This commit is contained in:
parent
e577a9e7aa
commit
1478088e19
40 changed files with 1125 additions and 657 deletions
CovidSafe
|
@ -228,19 +228,21 @@ class OTPViewController: UIViewController, RegistrationHandler {
|
|||
let session = UserDefaults.standard.string(forKey: "session") ?? ""
|
||||
RespondToAuthChallengeAPI.respondToAuthChallenge(session: session,
|
||||
code: OTP)
|
||||
{ (token: String?, error: Error?) in
|
||||
{ (response: ChallengeResponse?, error: Error?) in
|
||||
if let error = error {
|
||||
// User was not signed in. Display error.
|
||||
DLog(error.localizedDescription)
|
||||
result(.WrongOTP)
|
||||
return
|
||||
}
|
||||
guard let tokenToStore = token else {
|
||||
guard let tokenToStore = response?.token,
|
||||
let refreshToken = response?.refreshToken else {
|
||||
result(.WrongOTP)
|
||||
return
|
||||
}
|
||||
let keychain = KeychainSwift()
|
||||
keychain.set(tokenToStore, forKey: "JWT_TOKEN", withAccess: .accessibleAfterFirstUnlock)
|
||||
keychain.set(refreshToken, forKey: "REFRESH_TOKEN", withAccess: .accessibleAfterFirstUnlock)
|
||||
UserDefaults.standard.set(true, forKey: "HasUpdatedKeychainAccess")
|
||||
UserDefaults.standard.set(false, forKey: "ReauthenticationNeededKey")
|
||||
result(.Success)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue