|
@@ -94,8 +94,8 @@ class KMLoginWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
//登录界面点击下一步按钮
|
|
|
- self.loginView.nextAction = { [unowned self] (view, data) in
|
|
|
- KMRequestServerManager.manager.verificationEmail(userName: data.email, verifyEmailType: .login) { success, result in
|
|
|
+ self.loginView.nextAction = { [unowned self] (view, data, sender) in
|
|
|
+ KMRequestServerManager.manager.verificationEmail(userName: data.email, verifyEmailType: .login) { [unowned self] success, result in
|
|
|
if success {
|
|
|
self.model.email = data.email
|
|
|
self.logType = .loginInputPassword
|
|
@@ -120,11 +120,13 @@ class KMLoginWindowController: NSWindowController {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- return
|
|
|
+
|
|
|
} else {
|
|
|
self.loginView.showAlert(result: result)
|
|
|
}
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -135,7 +137,7 @@ class KMLoginWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
//注册界面点击下一步按钮
|
|
|
- self.registerView.nextAction = { [unowned self] (view, data) in
|
|
|
+ self.registerView.nextAction = { [unowned self] (view, data, sender) in
|
|
|
KMRequestServerManager.manager.verificationEmail(userName: data.email, verifyEmailType: .register) { success, result in
|
|
|
if success {
|
|
|
KMRequestServerManager.manager.getVerifyCode(verifyCodeType: .register, email: data.email) { success, result in
|
|
@@ -152,6 +154,8 @@ class KMLoginWindowController: NSWindowController {
|
|
|
} else {
|
|
|
self.registerView.showEmailAlert(result: result!)
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -170,7 +174,7 @@ class KMLoginWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
//验证码界面点击完成按钮
|
|
|
- self.verificationCodeView.doneAction = { [unowned self] (view, data) in
|
|
|
+ self.verificationCodeView.doneAction = { [unowned self] (view, data, sender) in
|
|
|
if view.inputType == .register {
|
|
|
KMRequestServerManager.manager.register(userName: data.email, password: data.password, verifyCode: data.verifyCode) { [unowned self] (success, requestData, result) in
|
|
|
if success {
|
|
@@ -181,6 +185,8 @@ class KMLoginWindowController: NSWindowController {
|
|
|
} else {
|
|
|
self.verificationCodeView.showAlert(result: result)
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
} else if view.inputType == .loginInputPassword {
|
|
|
KMRequestServerManager.manager.verificationCode(account: data.email, verifyCode: data.verifyCode, verifyCodeType: .resetPassword) { success, result in
|
|
@@ -191,25 +197,29 @@ class KMLoginWindowController: NSWindowController {
|
|
|
} else {
|
|
|
self.verificationCodeView.showAlert(result: result)
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//验证码界面点击重新发送验证码按钮
|
|
|
- self.verificationCodeView.reSendAction = { [unowned self] view in
|
|
|
+ self.verificationCodeView.reSendAction = { [unowned self] (view, textView) in
|
|
|
KMRequestServerManager.manager.getVerifyCode(verifyCodeType: self.verificationCodeView.verifyCodeType, email: self.verificationCodeView.model.email) { success, result in
|
|
|
if success {
|
|
|
self.verificationCodeView.resetTimer()
|
|
|
} else {
|
|
|
self.verificationCodeView.showAlert(result: result!)
|
|
|
}
|
|
|
+ textView.isSelectable = true
|
|
|
+ textView.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//loginInputPasswordView
|
|
|
//登录输入密码界面点击登录按钮
|
|
|
- self.loginInputPasswordView.loginAction = { [unowned self] (view, data) in
|
|
|
+ self.loginInputPasswordView.loginAction = { [unowned self] (view, data, sender) in
|
|
|
KMRequestServerManager.manager.login(email: data.email, password: data.password) { success, requestData, result in
|
|
|
if success {
|
|
|
KMRequestServerManager.manager.getUserInfo { success, data, error in
|
|
@@ -219,30 +229,11 @@ class KMLoginWindowController: NSWindowController {
|
|
|
loginWindowController = nil
|
|
|
}
|
|
|
}
|
|
|
- } else if result?.code == 318 {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.messageText = NSLocalizedString("Unable to log", comment: "")
|
|
|
- alert.informativeText = NSLocalizedString("Your account is currently being logged out and cannot be logged in.If you have questions, you can contact customer service", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Contact Customer", comment: ""))
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
|
|
|
- alert.beginSheetModal(for: view.window!) { result in
|
|
|
- if (result == .alertFirstButtonReturn) {
|
|
|
- // KMMailHelper.newEmail(withContacts: "support@pdfreaderpro.com", andSubjects: "")
|
|
|
- // NSWorkspace.shared.launchApplication("Mailto:support@pdfreaderpro.com")
|
|
|
- NSWorkspace.shared.open(URL(string: "mailto:support@pdfreaderpro.com")!)
|
|
|
-
|
|
|
- // let service = NSSharingService(named: NSSharingService.Name.composeEmail)
|
|
|
- // service?.recipients = ["support@pdfreaderpro.com"]
|
|
|
- // service?.subject = "Test Mail"
|
|
|
- // service?.perform(withItems: ["Test Mail body"])
|
|
|
- } else if result == .alertSecondButtonReturn {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
} else {
|
|
|
self.loginInputPasswordView.showAlert(result: result)
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -267,7 +258,7 @@ class KMLoginWindowController: NSWindowController {
|
|
|
|
|
|
//resetPasswordView
|
|
|
//重置密码界面点击完成按钮
|
|
|
- self.resetPasswordView.doneAction = { [unowned self] (view, data) in
|
|
|
+ self.resetPasswordView.doneAction = { [unowned self] (view, data, sender) in
|
|
|
KMRequestServerManager.manager.resetPassword(account: data.email, firstPassword: data.password, secondPassword: data.rePassword, verifyCode: data.verifyCode) {[unowned self] (success, result) in
|
|
|
if success {
|
|
|
self.model.email = data.email
|
|
@@ -275,6 +266,8 @@ class KMLoginWindowController: NSWindowController {
|
|
|
} else {
|
|
|
self.verificationCodeView.showAlert(result: result!)
|
|
|
}
|
|
|
+ sender.isEnabled = true
|
|
|
+ sender.alphaValue = 1
|
|
|
}
|
|
|
}
|
|
|
|