Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 185567a2 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

fix: harden auth session synchronization and login token handling

parent 8458cf22
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ fun GoogleOAuthScreen(
    retryVersion: Int,
    onDismissError: () -> Unit,
    onNavigateUp: () -> Unit,
    onGoogleLoginSubmit: (String, String) -> Unit,
    onGoogleLoginSubmit: (String, LoginOauthToken) -> Unit,
    modifier: Modifier = Modifier,
    webContent: @Composable (Modifier) -> Unit = { webModifier ->
        GoogleOAuthWebView(
+1 −2
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ class LoginFailureMessageResolver @Inject constructor(
            is LoginWorkflowFailure.RefreshValidationFailed ->
                failure.authError?.messageOrNull() ?: fallbackMessage

            is LoginWorkflowFailure.SubmissionFailed ->
                failure.throwable.localizedMessage ?: fallbackMessage
            is LoginWorkflowFailure.SubmissionFailed -> fallbackMessage
        }
    }

+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2026 e Foundation
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.feature.auth.login

class LoginOauthToken(
    private val value: String,
) {
    fun raw(): String = value

    override fun toString(): String = "LoginOauthToken(**redacted**)"

    override fun equals(other: Any?): Boolean {
        return other is LoginOauthToken && value == other.value
    }

    override fun hashCode(): Int = value.hashCode()
}
+2 −2
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@ sealed interface LoginUiEvent {
    data object AnonymousLoginSelected : LoginUiEvent
    data class GoogleLoginSubmitted(
        val email: String,
        val oauthToken: String,
        val oauthToken: LoginOauthToken,
    ) : LoginUiEvent

    data class MicrogLoginSubmitted(
        val email: String,
        val oauthToken: String,
        val oauthToken: LoginOauthToken,
    ) : LoginUiEvent

    data object NoGoogleLoginSelected : LoginUiEvent
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class LoginViewModel @Inject constructor(

    private fun initiateMicrogLogin(
        email: String,
        oauthToken: String,
        oauthToken: LoginOauthToken,
    ) {
        launchLoginSubmission(R.string.sign_in_microg_login_failed) {
            loginWorkflowCoordinator.submitMicrogLogin(email, oauthToken)
@@ -86,7 +86,7 @@ class LoginViewModel @Inject constructor(

    private fun initiateGoogleLogin(
        email: String,
        oauthToken: String,
        oauthToken: LoginOauthToken,
    ) {
        launchLoginSubmission(R.string.sign_in_failed_desc) {
            loginWorkflowCoordinator.submitGoogleLogin(email, oauthToken)
Loading