COVIDSafe code from version 1.14 (#27)

This commit is contained in:
COVIDSafe Support 2020-11-09 16:51:00 -08:00 committed by GitHub
parent 3ea83834f5
commit cf93ea43c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 370 additions and 141 deletions

View file

@ -109,7 +109,7 @@ class EncounterMessageManager {
private func fetchTempIdFromApi(onComplete: ((Error?, (String, Date)?) -> Void)?) {
DLog("Fetching tempId from API")
GetTempIdAPI.getTempId { (tempId: String?, expiry: Int?, error: Error?) in
GetTempIdAPI.getTempId { (tempId: String?, expiry: Int?, error: Error?, covidSafeError: CovidSafeAPIError?) in
guard error == nil else {
if let error = error as NSError? {
let code = error.code
@ -119,6 +119,13 @@ class EncounterMessageManager {
} else {
DLog("Cloud function error, unable to convert error to NSError.\(error!)")
}
if covidSafeError == .TokenExpiredError {
UserDefaults.standard.set(true, forKey: "ReauthenticationNeededKey")
onComplete?(CovidSafeAPIError.TokenExpiredError, nil)
return
}
// if we have an existing tempid and expiry, use that
if let msg = self.tempId, let exp = self.advertisementPayloadExpiry {
onComplete?(nil, (msg, exp))