Allow signing in again if authentication is pending or was unsuccessful

The local server that we spin up to receive OAuth callbacks isn't
called when an error occurs and it is non-trivial to do so with
next-auth. Besides, there could be cases where the user explicitly
closes the browser window before the callback can be invoked.

With this commit, the user can sign in even while an authentication
is still in progress. As opposed to waiting for at most 10 minutes
before killing the local HTTP server if we haven't received the callback,
we will repeatedly check for a response every second for 100 seconds.
This gives us a chance to determine whether a new authentication has started
in the meantime and, if so, abort the current authentication flow.
This commit is contained in:
Antonio Scandurra 2022-08-02 13:57:55 +02:00
parent 641768174d
commit aa09bc527f
2 changed files with 56 additions and 45 deletions

View file

@ -1811,7 +1811,7 @@ impl Workspace {
match &*self.client.status().borrow() {
client::Status::ConnectionError
| client::Status::ConnectionLost
| client::Status::Reauthenticating
| client::Status::Reauthenticating { .. }
| client::Status::Reconnecting { .. }
| client::Status::ReconnectionError { .. } => Some(
Container::new(