Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication: Addressing Debt #1202

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions Simplenote/AuthViewController+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension AuthViewController {
simplenoteTitleView.stringValue = "Simplenote"
simplenoteSubTitleView.textColor = .simplenoteGray50Color
simplenoteSubTitleView.stringValue = NSLocalizedString("The simplest way to keep notes.", comment: "Simplenote subtitle")

// Error Label
errorField.stringValue = ""
errorField.textColor = .red
Expand Down Expand Up @@ -93,18 +94,14 @@ extension AuthViewController {

@objc
var usernameText: String {
usernameField.stringValue?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
state.username
}

@objc
var passwordText: String {
passwordField.stringValue?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
state.password
}

var authWindowController: AuthWindowController? {
view.window?.windowController as? AuthWindowController
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 too!!


/// # All of the Action Views
///
private var allActionViews: [NSButton] {
Expand Down Expand Up @@ -234,11 +231,6 @@ extension AuthViewController {
// MARK: - Handlers
//
extension AuthViewController {

@IBAction
func switchToPasswordAuth(_ sender: Any) {
mode = AuthenticationMode.loginWithPassword
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one wasn't in use


@objc
func performSignupRequest() {
Expand All @@ -255,7 +247,7 @@ extension AuthViewController {
case .success:
self.presentSignupVerification(email: email)
case .failure(let result):
self.showAuthenticationError(forCode: result.statusCode, responseString: result.response)
self.showAuthenticationError(statusCode: result.statusCode, responseString: result.response)
}

self.stopActionAnimation()
Expand All @@ -271,7 +263,7 @@ extension AuthViewController {
}

@MainActor
func performLoginWithEmailRequestInTask() async {
private func performLoginWithEmailRequestInTask() async {
defer {
stopActionAnimation()
setInterfaceEnabled(true)
Expand All @@ -290,7 +282,7 @@ extension AuthViewController {
} catch {
// TODO: Once Xcode 16 goes GM, *please* wire Typed Errors here? (it'll always be a RemoteError instance)
let remoteError = error as? RemoteError
self.showAuthenticationError(forCode: remoteError?.statusCode ?? .zero, responseString: remoteError?.response)
self.showAuthenticationError(statusCode: remoteError?.statusCode ?? .zero, responseString: remoteError?.response)
}
}

Expand Down Expand Up @@ -318,7 +310,7 @@ extension AuthViewController {
} catch {
// TODO: Once Xcode 16 goes GM, *please* wire Typed Errors here? (it'll always be a RemoteError instance)
let remoteError = error as? RemoteError
self.showAuthenticationError(forCode: remoteError?.statusCode ?? .zero, responseString: remoteError?.response)
self.showAuthenticationError(statusCode: remoteError?.statusCode ?? .zero, responseString: remoteError?.response)
}
}

Expand Down Expand Up @@ -367,9 +359,9 @@ extension AuthViewController {

switch superView {
case usernameField:
state.username = usernameField.stringValue
state.username = usernameField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
case passwordField:
state.password = passwordField.stringValue
state.password = passwordField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy usernameText and passwordText had this trimming (L97 + L102 in this PR)

case codeTextField:
state.code = codeTextField.stringValue
default:
Expand Down Expand Up @@ -405,17 +397,9 @@ extension AuthViewController {
let vc = SignupVerificationViewController(email: email, authenticator: authenticator)
view.window?.transition(to: vc)
}

//TODO: Drop this method?
func presentMagicLinkRequestedView(email: String) {
guard let authWindowController else {
return
}

authWindowController.switchToMagicLinkRequestedUI(email: email)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in use any longer!

}


// MARK: - Login Error Handling
//
extension AuthViewController {
Expand Down
1 change: 0 additions & 1 deletion Simplenote/AuthViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@
- (void)presentPasswordResetAlert;
- (void)presentPasswordCompromisedAlert;
- (void)presentUnverifiedEmailAlert;
- (void)showAuthenticationErrorForCode:(NSInteger)responseCode responseString:(NSString *)responseString;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was triggering a warning. I've missed dropping the forward declaration, when ported to Swift


@end