mlem icon indicating copy to clipboard operation
mlem copied to clipboard

New Login Sheet

Open Sjmarf opened this issue 1 year ago • 1 comments

This PR implements the login sheet (including two-factor authentication) and the token refresh sheet. For testing purposes, a "Re-authenticate" button has been added to the account list in settings. The token refresh sheet is not yet invoked automatically when the token expires.

[!important] This PR is dependent on the changes made in this PR and the changes made in this PR.

Login flow:


Token refresh sheet, which will also show the 2FA page if needed:


The syntax for opening the login sheet is as follows:

// Open the login sheet and ask the user to pick an instance
navigation.openSheet(.login())

// Open the login sheet with the specified instance
navigation.openSheet(.login(.instance(instance))

// Open the reauth sheet 
navigation.openSheet(.login(.reauth(userStub))

Closes #1057

Sjmarf avatar May 14 '24 21:05 Sjmarf

The flow does not check if the account already exists before adding it.

If the account already exists, it will update the token of the existing account rather than trying to add a second one. Because LoginCredentialsView is used in the re-auth sheet, this provides the correct behavior in that case. You're correct that it doesn't provide any message if you try to login to an already logged-in account in the regular case - I can add an error message for it, though I doubt anyone will try to do this

Sjmarf avatar May 16 '24 06:05 Sjmarf