Skip to content

feat: add login flow & session management #10

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

Merged
merged 4 commits into from
Dec 12, 2024
Merged

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Dec 11, 2024

Closes #3.
Relates to #4.

  • Adds a stock About popup.
  • Adds a SecureSession that writes the session token to the keychain, and the server URL to UserDefaults.
  • Adds an initial Client for the Swift coderd SDK. Currently only supports the users endpoint for validating a session token.
Screen.Recording.2024-12-11.at.5.40.42.pm.mov

The 'generate a token' hyperlink takes the user to /cli-auth.

Copy link
Member Author

ethanndickson commented Dec 11, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson marked this pull request as ready for review December 11, 2024 06:47
Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

LGTM, I like the tests

@ethanndickson
Copy link
Member Author

ethanndickson commented Dec 11, 2024

image image

I didn't like that the form wasn't centered in the window, so it looks like this now. The macOS screenshot tool tells me the padding at the top and bottom is the same (50px).

I don't love the progress view (spinner), so I might get rid of it. I think the buttons disabling/dimming is enough feedback.

}

enum ClientError: Error {
case unexpectedStatusCode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case unexpectedStatusCode
case unexpectedStatusCode(Int)

This lets you store the status code

func user(_ ident: String) async throws -> User {
let resp = await request("/api/v2/users/\(ident)", method: .get)
guard let response = resp.response, response.statusCode == 200 else {
throw ClientError.unexpectedStatusCode
Copy link
Collaborator

Choose a reason for hiding this comment

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

fine for now, but we should be parsing the generic error responses for debugging/troubleshooting

e.g. https://github.com/coder/coder/blob/b39becba66f1c6ad9c8d73694b0d8779cf7467a2/codersdk/client.go#L495

}
}
}.onReceive(inspection.notice) { self.inspection.visit(self, $0) } // ViewInspector
Copy link
Member Author

@ethanndickson ethanndickson Dec 12, 2024

Choose a reason for hiding this comment

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

I absolutely hate that you need to modify your UI code to get the tests to work, but you do. If nalexn/ViewInspector#231 is ever resolved you'd be able to just wrap the view with the inspector at test-time instead.

@ethanndickson ethanndickson merged commit c070ac7 into main Dec 12, 2024
1 check passed
@ethanndickson ethanndickson deleted the ethan/login-flow branch January 23, 2025 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build the Coder login UX flow
3 participants