Skip to content
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

Handle invalid tokens gracefully #768

Merged
merged 39 commits into from
Dec 16, 2019
Merged

Handle invalid tokens gracefully #768

merged 39 commits into from
Dec 16, 2019

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Dec 13, 2019

Handle invalid token by cleaning local data.

Also handle the soft logout case (#281)

The login/registration flow has been touched, they have to be tested again.

Also we have open issues on Synapse which makes that all does not work properly:

For reviewers: all cases should be handled. Please also check that there are no regression on the sign in and sign up flows. Thanks

Some screenshots:
Invalid token:
SoftLogoutHard
Soft logout with password:
SoftLogoutPasswordMode
SoftLogout when login flow is not supported (for SSO the wording of the button is "Continue with SSO")
SoftLogoutUnsupportedMode

@bmarty bmarty added this to the Sprint7 milestone Dec 13, 2019
// For M_LIMIT_EXCEEDED
@Json(name = "retry_after_ms") val retryAfterMillis: Long? = null,
// For M_UNKNOWN_TOKEN
@Json(name = "soft_logout") val isSoftLogout: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be optional?
I am not sure how moshi manages non optional with default value

Copy link
Member Author

Choose a reason for hiding this comment

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

It's working like that... Even when the param is not present...

const val M_USER_IN_USE = "M_USER_IN_USE"
/** Sent when the room alias given to the createRoom API is already in use. */
const val M_ROOM_IN_USE = "M_ROOM_IN_USE"
/** (Not documented yet) */
Copy link
Member

Choose a reason for hiding this comment

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

👌 ;)

EventBus.getDefault().post(GlobalError.ConsentNotGivenError(matrixError.consentUri))
} else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
&& matrixError.code == MatrixError.M_UNKNOWN_TOKEN) {
// TODO Check that this is ok during the login flow
Copy link
Member

Choose a reason for hiding this comment

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

TODO?

Copy link
Member Author

Choose a reason for hiding this comment

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

cleaned up, thanks

Copy link
Member Author

Choose a reason for hiding this comment

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

(and checked :))


internal interface SignInAgainTask : Task<SignInAgainTask.Params, Unit> {
data class Params(
val password: String
Copy link
Member

Choose a reason for hiding this comment

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

store password as char[] instead of string? and wipe it when finished.

Copy link
Member Author

Choose a reason for hiding this comment

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

isn't it too much paranoid?


mainActivityStarted = true

MainActivity.restartApp(this,
Copy link
Member

@BillCarsonFr BillCarsonFr Dec 13, 2019

Choose a reason for hiding this comment

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

restartApp is making me thinking that there still is the exit(0) thing

Copy link
Member Author

Choose a reason for hiding this comment

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

No exit(0) :)


override fun bind(holder: Holder) {
holder.textView.text = text
holder.buttonView.setOnClickListener { listener?.invoke() }
Copy link
Member

Choose a reason for hiding this comment

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

create clickListener in ViewHolder (and bind the listener in bind())?

Copy link
Member Author

Choose a reason for hiding this comment

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

we should do this in another optimization PR.
Also this is a copy paste of ErrorWithRetryItem class

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Some remarks

@bmarty bmarty changed the title Handle invalid tokens gracefully - WIP Handle invalid tokens gracefully Dec 13, 2019
Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Re-login with sso tested ok
Tested the clear data, and checked that filesystem related info is cleared

@bmarty bmarty merged commit 3feb2d8 into develop Dec 16, 2019
@bmarty bmarty deleted the feature/soft_logout branch December 16, 2019 13:57
This was referenced Dec 16, 2019
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.

2 participants