When MFA login fails, display an orange banner at the top of the screen
laurent22 opened this issue · comments
Operating system
Windows
Joplin version
3.0.0
Desktop version info
No response
Current behaviour
Currently when enabling MFA, the next sync operation is going to fail and it will just show this in the sidebar:
![image](https://private-user-images.githubusercontent.com/1285584/341481984-83002c5f-9634-48fc-a53a-f67c65aa72fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk1MTcyOTIsIm5iZiI6MTcxOTUxNjk5MiwicGF0aCI6Ii8xMjg1NTg0LzM0MTQ4MTk4NC04MzAwMmM1Zi05NjM0LTQ4ZmMtYTUzYS1mNjdjNjVhYTcyZmIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjdUMTkzNjMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTZhMGQ5MDQzMjM3ZThlZmIyMGM0NDBiMDFhM2I2YzIwNDU4NjViODZiZWVkYjM5YTA1OThjYzc0ZDcwN2Y2YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.WqG9XMBubbN18MA9NhkIen326dC80eNtNNBLY-qgCnw)
It's easy to miss it, so instead we should display a banner at the top (using renderNotificationMessage()
) telling the user that they need to login. Clicking on the banner should open the Joplin Cloud screen for login (just like when we click on the Synchronize button)
The same should apply to mobile
Expected behaviour
No response
Logs
No response
I'm making a change that might be bigger than the issue seems to ask, but the issue is that when I was checking the implementation I realized that there are many places where the connection to Joplin Cloud can fail.
THe current implementation of isAuthenticated
while is useful to check if the user has any credentials, it will return the wrong response if the credentials are invalid (mfa was enabled, or the application record was deleted on the website). This happened because the check to see if the user was authenticated was just seeing if a sessionId
existed.
The problem was that while 'isAuthenticatedwould return true, we could see a error happen in the Synchronizer or inside of a call to
config-shared.checkSyncConfig`, meaning it was harder to be sure if the user was logged in or not.
My solution to fix this was to add a checkConfig
inside the SyncTargetJoplinCloud.isAuthenticated
, if we get a negative response I already redirect the user to JoplinCloudLoginScreen
, avoiding the necessity of adding a banner to inform the user or keeping track of another state in the application.
There is one drawback: it will be harder for the user to see the error message returned by the server since it will only be present inside the log on console/generated by Logger
I'm adding videos of how the implementation I did work:
First login (application without any state):
first_login.mp4
User was logged in, but credentials turned invalid (mfa was enabled or application was deleted on website):
credential_invalid.mp4
When Joplin Cloud is offline:
joplin_cloud_offline.mp4
Thanks for clarifying the situation, but regarding this:
My solution to fix this was to add a
checkConfig
inside theSyncTargetJoplinCloud.isAuthenticated
, if we get a negative response I already redirect the user toJoplinCloudLoginScreen
, avoiding the necessity of adding a banner to inform the user or keeping track of another state in the application.
The problem is that synchronisation might fail in the background, so in that case we don't want to jump to the login screen without asking the user.
The problem is that synchronisation might fail in the background, so in that case we don't want to jump to the login screen without asking the user.
I don't think this will be a problem, I'm not going to change anything about synchronisation, I'm just making isAuthenticated
more robust. I'm going to open a PR.