CryptoPassphrase  Diff

Differences From Artifact [209b94f8a1]:

To Artifact [7294aad127]:


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
                                      preferredStyle: .alert)
        alert.addAction(
            UIAlertAction(title: "OK", style: .default, handler: nil))
        controller.present(alert, animated: true, completion: nil)
    }

    @IBAction func done(_ sender: Any) {
        guard let name = nameField?.text?.ofObject else { return }
        guard let lengthString = lengthField?.text?.ofObject else { return }

        guard name.length > 0 else {
            showAlert(controller: self, title: "Name missing",
                      message: "Please enter a name.")
            return
        }

        var lengthValid = true
        var length: size_t = 0
        OFException.try({
            length = lengthString.decimalValue

            if length < 3 || length > 64 {
                lengthValid = false
            }
        }, catch: { (OFException) in
            lengthValid = false
        })

        guard lengthValid else {
            showAlert(controller: self, title: "Invalid length",
                      message: "Please enter a number between 3 and 64.")
            return
        }

        guard let siteStorage = mainViewController?.siteStorage else { return }

        guard !siteStorage.hasSite(name) else {
            showAlert(controller: self, title: "Site Already Exists",
                      message: "Please pick a name that does not exist yet.")
            return
        }

        let keyFile = self.keyFile?.ofObject
        siteStorage.setSite(name, length: length,
                            legacy: legacySwitch?.isOn ?? false,
                            keyFile: keyFile)
        mainViewController?.reset()
        navigationController?.popViewController(animated: true)
    }

    @IBAction func cancel(_ sender: Any) {
        navigationController?.popViewController(animated: true)
    }







|
|

|





<
<
<
<
|
<
<
<
<
<
<
<
<













<

|
|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73




74








75
76
77
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
                                      preferredStyle: .alert)
        alert.addAction(
            UIAlertAction(title: "OK", style: .default, handler: nil))
        controller.present(alert, animated: true, completion: nil)
    }

    @IBAction func done(_ sender: Any) {
        guard let name = nameField?.text else { return }
        guard let lengthString = lengthField?.text else { return }

        guard name.count > 0 else {
            showAlert(controller: self, title: "Name missing",
                      message: "Please enter a name.")
            return
        }





        guard let length = UInt(lengthString), length >= 3, length <= 64 else {








            showAlert(controller: self, title: "Invalid length",
                      message: "Please enter a number between 3 and 64.")
            return
        }

        guard let siteStorage = mainViewController?.siteStorage else { return }

        guard !siteStorage.hasSite(name) else {
            showAlert(controller: self, title: "Site Already Exists",
                      message: "Please pick a name that does not exist yet.")
            return
        }


        siteStorage.setSite(name, length: length,
                            isLegacy: legacySwitch?.isOn ?? false,
                            keyFile: self.keyFile)
        mainViewController?.reset()
        navigationController?.popViewController(animated: true)
    }

    @IBAction func cancel(_ sender: Any) {
        navigationController?.popViewController(animated: true)
    }