-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnterPasswordViewController.swift
More file actions
67 lines (44 loc) · 2.15 KB
/
Copy pathEnterPasswordViewController.swift
File metadata and controls
67 lines (44 loc) · 2.15 KB
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
62
63
64
65
66
67
//
// 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 {
@IBAction func nextPressed(sender: UIButton) {
HUD.show(.LabeledProgress(title: "Creating Account", subtitle: "Please Wait"))
Asahi.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
log.debug("Do something!")
})
}
.error{ err -> Void in
// On the off chance an account already exists
self.login(Settings.sharedInstance.userEmail!, pwd: self.pwdTextField.text!)
}
}
override func recoverFromLoginFailure() {
super.recoverFromLoginFailure()
recoverFromRegFailure()
}
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
self.navigationController!.popToRootViewControllerAnimated(true)
}
alertController.addAction(cancelAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Settings.sharedInstance.userEmail = emailTextField.text
}
}