Skip to content

deletePasscode() Not Getting Called. #12

@AndyIbanez

Description

@AndyIbanez

Hey guys.

First, thanks for forking and reviving this project. While the documentation could use some improvement, I really like this component and it's a shame the original maintainer has basically abandoned the project.

But anyway, to the point:

Like the title says, deletePasscode() doesn't seem to be getting called at all. Here's some code:

It presents the view controller without any issues:

        let configuration = PasscodeLockConfiguration() 
                let passcodeViewController = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration)
                presentViewController(passcodeViewController, animated: true, completion: nil)

The PasscodeLockConfiguration and PasscodeLockRepository look like this:

let MignoriUserAccount = "com.ios.fairese.Mignori.LocksmithUserAccount.Default"

struct PasscodeLockConfiguration: PasscodeLockConfigurationType {

    let repository: PasscodeRepositoryType
    let passcodeLength = 4
    var isTouchIDAllowed = Settings.lockScreenPasscodeSettingsSupportTouchID
    let shouldRequestTouchIDImmediately = true
    let maximumInccorectPasscodeAttempts = -1

    init(repository: PasscodeRepositoryType) {

        self.repository = repository
    }

    init() {
        self.repository = LocksmithPasscodeRepository()
    }
}

class LocksmithPasscodeRepository: PasscodeRepositoryType {

    var passcode: [String]? {
        return Locksmith.loadDataForUserAccount(MignoriUserAccount)?["passcode"] as? [String]
    }

    var hasPasscode: Bool {
        get {
            return Locksmith.loadDataForUserAccount(MignoriUserAccount) != nil
        }
    }

    func savePasscode(passcode: [String]) {
        do {
            Collector.logEvent("Passcode", withParameters: ["State" : "Enabled"])
            try Locksmith.deleteDataForUserAccount(MignoriUserAccount) // There is no "update password" method sooo yeah.
            try Locksmith.saveData(["passcode": passcode], forUserAccount: MignoriUserAccount)
        } catch let e {
            Collector.logEvent("Failed to Save Passcode", withParameters: ["message" : "\(e)"])
        }
    }

    func deletePasscode() {
        print("bro?")
        do {
            try Locksmith.deleteDataForUserAccount(MignoriUserAccount)
            Collector.logEvent("Passcode", withParameters: ["State" : "Disabled"])
        } catch let e {
            print("Wut err \(e)")
            Collector.logEvent("Failed to Remove Passcode", withParameters: ["message" : "\(e)"])
        }
    }
}

The print("bro?") line never gets executed, so let alone the rest of the lines inside the deletePasscode method. The other three methods get called with no issue, but for some reason deletePasscode doesn't get called, not even when the view controller is presented and I put in my passcode to remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions