-
Notifications
You must be signed in to change notification settings - Fork 226
Add support for login link #4752
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
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4752 +/- ##
===========================================
+ Coverage 80.31% 80.32% +0.01%
===========================================
Files 2127 2135 +8
Lines 56330 56441 +111
Branches 7057 7069 +12
===========================================
+ Hits 45241 45336 +95
- Misses 8672 8688 +16
Partials 2417 2417 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
While testing it, I got this error (and a dialog for it), then the log in progressed to the 'confirm your identity' screen soon after:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. I'd approve the PR, but it seems risky with the issue I found above.
.idea/codeStyles/Project.xml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this accidentally added? I think you mentioned this was generated by the IDE before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :/
Does your IDE removes the added section? I do not know how to get ride of this change that I always have to not commit.
I'll revert the change for this PR.
switchToNotLoggedInFlow(params) | ||
} else { | ||
// Just ignore the login link if we already have a session | ||
Timber.w("Login link ignored, we already have a session") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should try to give some feedback to the user in this case, although I guess there's no easy way to display a dialog/toast from here 🫤 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class LoginParams( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add some docs for what these are used for?
get() = loginFlowAction.value | ||
|
||
@Composable | ||
fun Start() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could behave like collectAsState
, directly returning the loginFlowAction
current value so you don't have to expose it separately?
private val defaultLoginUserStory: DefaultLoginUserStory, | ||
private val webClientUrlForAuthenticationRetriever: WebClientUrlForAuthenticationRetriever, | ||
) { | ||
private lateinit var loginFlowAction: MutableState<AsyncData<LoginFlow>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can initialise the state here instead of in the Start
composable and it'll work the same, without the lateinit added complexity.
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
class LoginHelper @Inject constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some docs for this class would be quite helpful.
import io.element.android.libraries.ui.strings.CommonStrings | ||
|
||
@Composable | ||
fun LoginFlowView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's named like this because it's based on the LoginFlow
value, but it kind of conflicts with the FlowNode
components we have, so it took me a while to understand this is not managing a flow of screen/components. Maybe we should try thinking about a better name...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I do not like this name either. Do you have a better idea? I can't think of any...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename LoginFlow
to AccountSetup
so you have:
sealed interface AccountSetup {
data object PasswordLogin : AccountSetup
data class OidcLogin(val oidcDetails: OidcDetails) : AccountSetup
data class AccountCreation(val url: String) : AccountSetup
}
And this can now be AccountSetupView
. I can't come up with a better name, it's tricky one 🫤 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will go for LoginMode
and extract this interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, although AccountCreation
is technically not a login mode 🤓 .
Move LoginFlow to package io.element.android.features.login.impl.login Rename some implementation of LoginMode Rename LoginFlowView to LoginModeView
Using launchMode singleTask to avoid multiple instances of the Activity when the app is already open. This is important for incoming share and for opening the application from a mobile.element.io link. Closes #4074
Thanks for reporting. It was due to multiple instance of the application to run in parallel. It was possible when opening a mobile.element.io link from an application that do not create a separate task like Google Keep Note. Google Chrome create a separate task. I fixed that in 59a508f Note that this also has the effect to close #4074 and incoming share still work as expected. |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, now that everything works we can approve it!
Content
Add support for login link
Motivation and context
Let the application be opened when the user opens link like
https://mobile.element.io/element?account_provider=example.org&login_hint=mxid:@alice:example.org
Closes #4705
Screenshots / GIFs
SignInDeepLink.mp4
Tests
Tested devices
Checklist