diff --git a/src/views/Authorization/LoginView.jsx b/src/views/Authorization/LoginView.jsx index 48a3a92..ebe6c45 100644 --- a/src/views/Authorization/LoginView.jsx +++ b/src/views/Authorization/LoginView.jsx @@ -699,14 +699,27 @@ const LoginView = () => { variant='soft' size='lg' sx={{ mt: 3, mb: 2 }} - onClick={() => { - SocialLogin.login({ - provider: 'google', - options: { scopes: ['profile', 'email', 'openid'] }, - }).then(user => { + onClick={async () => { + try { + // Clear any cached session so the account picker shows + await SocialLogin.logout({ provider: 'google' }).catch( + () => {}, + ) + const user = await SocialLogin.login({ + provider: 'google', + options: { scopes: ['profile', 'email', 'openid'] }, + }) console.log('Google user', user) loggedWithProvider('google', user.result) - }) + } catch (error) { + console.error('Google login error:', error) + showError({ + title: 'Google Login Failed', + message: `Couldn't log in with Google, please try again${ + error?.message ? `: ${error.message}` : '' + }`, + }) + } }} >