passwordExpireDays not decoded into model from response
Shagans982 opened this issue · 4 comments
On the PASSWORD_WARN
status we are getting back passwordExpireDays
value but after decoding the response, its never added to the model.
{"stateToken":"redacted,"expiresAt":"2019-08-22T22:57:23.000Z","status":"PASSWORD_WARN","_embedded":{"user":{"id":"redacted","passwordChanged":"2019-08-12T21:27:37.000Z","profile":{"login":"redacted","firstName":"MobileTest2","lastName":"Test","locale":"en","timeZone":"America/Los_Angeles"}},"policy":{"
expiration":{"passwordExpireDays":79}
,"complexity":{"minLength":8,"minLowerCase":1,"minUpperCase":1,"minNumber":1,"minSymbol":1,"excludeUsername":true},"age":{"minAgeMinutes":0,"historyCount":8}}},"_links":{"next":{"name":"changePassword","href":"redacted","hints":{"allow":["POST"]}},"skip":{"name":"skip","href":"redacted","hints":{"allow":["POST"]}},"cancel":{"href":"redacted","hints":{"allow":["POST"]}}}}
but the model shows: (partial)
- some : "MobileTest2" ▿ lastName : Optional<String> - some : "Test" ▿ locale : Optional<String> - some : "en" ▿ timeZone : Optional<String> - some : "America/Los_Angeles" - recoveryQuestion : nil - target : nil
▿
policy : Optional
▿ some : Policy
▿ rememberDevice : RememberDevice
- allowRememberDevice : nil
- rememberDeviceByDefault : nil
- rememberDeviceLifetimeInMinutes : nil
` - authentication : nil
- factor : nil
- factors : nil`
Look like in OktaModels the logic is wrong.
public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() if let rememberDevice = try? container.decode(RememberDevice.self) { self = .rememberDevice(rememberDevice) } else if let password = try? container.decode(Password.self) { self = .password(password) } else { throw DecodingError.typeMismatch( Policy.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for Policy") ) } }
It ignores password if remember device is present. If I make password the first case, it works.
@Shagans982 , thanks for reporting this and your investigation. Issue is being addressed
Thanks - Can you share the fix that was made? Server side?
@Shagans982 , sure, pr is opened - #102