-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnterPasswordViewController.swift
61 lines (45 loc) · 2.09 KB
/
EnterPasswordViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// EnterPasswordViewController.swift
// Absinthe-iOS
//
// Created by Mitchell Kahn on 9/20/16.
// Copyright © 2016 AppDelegates. All rights reserved.
//
import UIKit
import PKHUD
// A lot of this VCs functionality is in the Base VC
class EnterPasswordViewController: LoginBaseViewController {
let segueId = "fromPasswordToMainTabs"
@IBAction func nextPressed(_ sender: UIButton) {
HUD.show(.labeledProgress(title: "Creating Account", subtitle: "Please Wait"))
OGCloud.sharedInstance.register(Settings.sharedInstance.userEmail!,
password: pwdTextField.text!,
user: [ "firstName": Settings.sharedInstance.userFirstName!,
"lastName": Settings.sharedInstance.userLastName! ])
.then{ response -> Void in
HUD.flash(.labeledSuccess(title: "All Set!", subtitle: "Welcome to Ourglass"), delay: 1.0, completion: { (_) in
self.performSegue(withIdentifier: self.segueId, sender: nil)
})
}
.catch{ err -> Void in
// On the off chance an account already exists
self.loginWithSegue(Settings.sharedInstance.userEmail!, pwd: self.pwdTextField.text!, segueId: self.segueId)
}
}
override func recoverFromLoginFailure() {
super.recoverFromLoginFailure()
recoverFromRegFailure()
}
override func viewDidLoad() {
super.viewDidLoad()
pwdTextField.useCustomBottomBorder()
}
func recoverFromRegFailure(){
HUD.hide()
let alertController = UIAlertController(title: "Uh Oh", message: "There was a problem registering. Do you already have an account with that email?", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Try Again", style: .cancel) { (action) in
}
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
}