You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use SwiftPasscodeLock in a system where multiple users can use an app in a shop environment.
The user needs to identify themselves using a PIN before they can use the system - this PIN maps to an identity token that is used in API requests.
I have a map of PIN code -> token in the keychain, so the PIN code effectively acts like a username.
It doesn't seem possible to use SwiftPasscodeLock in this scenario because it assumes there is only one PIN.
Looking at the code, I can think of various ways of implementing this but for now, it looks like the simplest change that would get me where I want to be is to change the PasscodeRepositoryType protocol so it doesn't return a passcode, but has a query method instead:
The passcode checkin EnterPasscodeState.acceptPasscode() would need to change from:
guardlet currentPasscode = lock.repository.passcode else{return}
if passcode == currentPasscode {
To:
if lock.repository.checkPasscode(passcode){
I can then implement this function however I want and in my case, check whether the PIN exists in the keychain (amongst many).
The downside is this is not backwards compatible, but a transitional API might be to not remove the var passcode { get } declaration and provide a default implementation of checkPasscode in the protocol:
I'm trying to use SwiftPasscodeLock in a system where multiple users can use an app in a shop environment.
The user needs to identify themselves using a PIN before they can use the system - this PIN maps to an identity token that is used in API requests.
I have a map of PIN code -> token in the keychain, so the PIN code effectively acts like a username.
It doesn't seem possible to use SwiftPasscodeLock in this scenario because it assumes there is only one PIN.
Looking at the code, I can think of various ways of implementing this but for now, it looks like the simplest change that would get me where I want to be is to change the
PasscodeRepositoryType
protocol so it doesn't return a passcode, but has a query method instead:The passcode checkin
EnterPasscodeState.acceptPasscode()
would need to change from:To:
I can then implement this function however I want and in my case, check whether the PIN exists in the keychain (amongst many).
The downside is this is not backwards compatible, but a transitional API might be to not remove the
var passcode { get }
declaration and provide a default implementation ofcheckPasscode
in the protocol:Any thoughts?
The text was updated successfully, but these errors were encountered: