2018-11-19 16:58:23 +01:00
|
|
|
//
|
|
|
|
// NoteBiometricViewController.swift
|
|
|
|
// Friendvatars
|
|
|
|
//
|
|
|
|
// Created by Dawid Kubicki on 19/11/2018.
|
|
|
|
// Copyright © 2018 Razeware. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2018-11-19 23:41:12 +01:00
|
|
|
import KeychainAccess
|
2018-11-19 16:58:23 +01:00
|
|
|
|
|
|
|
class NoteBiometricViewController: UIViewController {
|
|
|
|
|
2018-11-19 23:41:12 +01:00
|
|
|
@IBAction func isSignOut(_ sender: Any) {
|
|
|
|
try? AuthController.signOut()
|
|
|
|
}
|
|
|
|
@IBOutlet weak var txtSecret: UITextField!
|
|
|
|
@IBOutlet weak var imgBio: UIImageView!
|
|
|
|
@IBOutlet weak var lblSecret: UILabel!
|
|
|
|
|
|
|
|
let keychain = Keychain(service: "com.dawidkubicki.Friendvatars")
|
|
|
|
|
2018-11-19 16:58:23 +01:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
2018-11-19 23:41:12 +01:00
|
|
|
if(biometricType == .touchID) {
|
|
|
|
imgBio.image = UIImage(named: "TouchID")
|
|
|
|
} else if(biometricType == .faceID) {
|
|
|
|
imgBio.image = UIImage(named: "FaceID")
|
|
|
|
} else if(biometricType == .none) {
|
|
|
|
print("Nie ma możliwości użycia biometrycznego uwierzytelniania")
|
|
|
|
}
|
2018-11-19 16:58:23 +01:00
|
|
|
}
|
|
|
|
|
2018-11-19 23:41:12 +01:00
|
|
|
@IBAction func storeSecret(_ sender: Any) {
|
|
|
|
DispatchQueue.global().async {
|
|
|
|
do {
|
|
|
|
try self.keychain
|
|
|
|
.accessibility(.whenPasscodeSetThisDeviceOnly, authenticationPolicy: .userPresence)
|
|
|
|
.set(self.txtSecret.text!, key: "secret")
|
|
|
|
} catch let error {
|
|
|
|
print(error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func getSecret(_ sender: Any) {
|
|
|
|
DispatchQueue.global().async {
|
|
|
|
do {
|
|
|
|
let secret = try self.keychain
|
|
|
|
.authenticationPrompt("Zaloguj się biometrycznie, aby zobaczyć notatkę")
|
|
|
|
.get("secret")
|
|
|
|
self.lblSecret.text = "Twoja ukryta notatka to: \(secret!)"
|
|
|
|
} catch let error {
|
|
|
|
print(error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-19 16:58:23 +01:00
|
|
|
/*
|
|
|
|
// MARK: - Navigation
|
|
|
|
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
|
|
// Get the new view controller using segue.destination.
|
|
|
|
// Pass the selected object to the new view controller.
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|