diff --git a/app/src/main/java/it/bz/noi/community/MainActivity.kt b/app/src/main/java/it/bz/noi/community/MainActivity.kt index b64fe09..d154805 100644 --- a/app/src/main/java/it/bz/noi/community/MainActivity.kt +++ b/app/src/main/java/it/bz/noi/community/MainActivity.kt @@ -122,7 +122,7 @@ class MainActivity : AppCompatActivity() { } is AuthStateStatus.Error, AuthStateStatus.Unauthorized.UserAuthRequired, - AuthStateStatus.Unauthorized.NotValidRole -> { + is AuthStateStatus.Unauthorized.NotValidRole -> { goToOnboardingActivity() } else -> { diff --git a/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt b/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt index 6a2f1f0..130339a 100644 --- a/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt +++ b/app/src/main/java/it/bz/noi/community/oauth/AuthManager.kt @@ -48,7 +48,7 @@ sealed class AuthStateStatus { sealed class Unauthorized : AuthStateStatus() { object UserAuthRequired : Unauthorized() object PendingToken : Unauthorized() - object NotValidRole : Unauthorized() + data class NotValidRole(val emailAddress: String) : Unauthorized() } data class Authorized(val state: AuthState) : AuthStateStatus() @@ -72,7 +72,7 @@ object AuthManager { /** * Check if the user has a valid email, that is if it is allowed to use the app. */ - private suspend fun AuthState.isEmailValid(): Boolean { + private suspend fun AuthState.isEmailValid(): Pair { fun String.isDimensionEmail() = endsWith("@dimension.it") @@ -81,23 +81,23 @@ object AuthManager { fun String.isWhitelisted() = isDimensionEmail() || isGooglePlayReviewEmail() return try { - val token = obtainFreshToken() ?: return false + val token = obtainFreshToken() ?: return ("" to false) val mail: String = getUserInfo(token, obtainAuthServiceConfig()).let { res -> if (res.status == Status.SUCCESS) { res.data } else { null } - }?.email ?: return false + }?.email ?: return "" to false if (mail.isWhitelisted()) { - return true + return mail to true } val contacts = RetrofitBuilder.communityApiService.getContacts(token.bearer()).contacts - contacts.any { it.matches(mail) } + mail to contacts.any { it.matches(mail) } } catch (ex: Exception) { - false + "" to false } } @@ -119,11 +119,11 @@ object AuthManager { ) ) - !validRole -> AuthStateStatus.Unauthorized.NotValidRole + true || !validRole -> AuthStateStatus.Unauthorized.NotValidRole("") authState.isAuthorized -> { - authState.isEmailValid().let { isValid -> + authState.isEmailValid().let { (mail, isValid) -> if (!isValid) { - AuthStateStatus.Unauthorized.NotValidRole + AuthStateStatus.Unauthorized.NotValidRole(mail) } else { AuthStateStatus.Authorized(authState) } diff --git a/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt b/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt index fa9f822..7506de1 100644 --- a/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt +++ b/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt @@ -19,6 +19,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs import com.google.firebase.crashlytics.FirebaseCrashlytics import it.bz.noi.community.R import it.bz.noi.community.databinding.FragmentAuthorizationErrorBinding @@ -35,6 +36,8 @@ class AuthorizationErrorFragment : BaseOnboardingFragment() { private var _binding: FragmentAuthorizationErrorBinding? = null private val binding get() = _binding!! + private val args by navArgs() + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -70,7 +73,10 @@ class AuthorizationErrorFragment : BaseOnboardingFragment() { binding.message.apply { movementMethod = LinkMovementMethod.getInstance() text = buildSpannedString { - append(getString(R.string.outsider_user_body)) + append( + getString(R.string.outsider_user_body, args.emailAddress) + .replace("() ", "") // Remove blank email address. + ) val jobsSnippet = getString(R.string.outsider_user_body_link_1_part) addClickableSpan(jobsSnippet) { try { diff --git a/app/src/main/java/it/bz/noi/community/ui/onboarding/OnboardingFragment.kt b/app/src/main/java/it/bz/noi/community/ui/onboarding/OnboardingFragment.kt index 56e61ab..a58ed59 100644 --- a/app/src/main/java/it/bz/noi/community/ui/onboarding/OnboardingFragment.kt +++ b/app/src/main/java/it/bz/noi/community/ui/onboarding/OnboardingFragment.kt @@ -88,9 +88,9 @@ class OnboardingFragment : BaseOnboardingFragment() { showLoginInterface(false) onboardingActivity?.goToMainActivity() } - AuthStateStatus.Unauthorized.NotValidRole -> { + is AuthStateStatus.Unauthorized.NotValidRole -> { showLoginInterface(false) - findNavController().navigate(OnboardingFragmentDirections.loginToError()) + findNavController().navigate(OnboardingFragmentDirections.loginToError(status.emailAddress)) } else -> { showLoginInterface(true) diff --git a/app/src/main/res/navigation/onboarding.xml b/app/src/main/res/navigation/onboarding.xml index 4acc71e..4f5da24 100644 --- a/app/src/main/res/navigation/onboarding.xml +++ b/app/src/main/res/navigation/onboarding.xml @@ -22,7 +22,11 @@ SPDX-License-Identifier: CC0-1.0 + android:label="@string/warning_title" > + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index de79610..173e763 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -112,7 +112,7 @@ Please do not edit this file by hand, use the export function from Google Sheet. Datenschutzrichtlinie Oh no! Hoppla, das hat leider nicht geklappt! - Die angegebene E-Mail-Adresse scheint in unserer Datenbank nicht auf. \n \nDiese App ist den Mitgliedern der NOI-Community vorbehalten. Wenn du Teil davon bist, prüfe bitte die angegebene E-Mail-Adresse und versuch es noch einmal. Klappt es dann immer noch nicht, schreib uns bitte eine E-Mail an community@noi.bz.it. \n \nDu möchtest auch zur NOI-Community gehören? Hier geht’s zu unseren Job-Angeboten. + Die angegebene E-Mail-Adresse (%1$s) scheint in unserer Datenbank nicht auf. \n \nDiese App ist den Mitgliedern der NOI-Community vorbehalten. Wenn du Teil davon bist, prüfe bitte die angegebene E-Mail-Adresse und versuch es noch einmal. Klappt es dann immer noch nicht, schreib uns bitte eine E-Mail an community@noi.bz.it. \n \nDu möchtest auch zur NOI-Community gehören? Hier geht’s zu unseren Job-Angeboten. Job-Angeboten Hallo! Deine Anmeldung war erfolgreich diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 505f254..7d981fc 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -112,7 +112,7 @@ Please do not edit this file by hand, use the export function from Google Sheet. Privacy policy Oh no! Oops, that didn\'t work! - The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! + The e-mail address you provided (%1$s) does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! here Hello! Your registration has been successful diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 8f8ae6d..0918e93 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -112,7 +112,7 @@ Please do not edit this file by hand, use the export function from Google Sheet. Informativa sulla privacy Oh no! Ops, qualcosa è andato storto! - L\'indirizzo e-mail inserito non è presente nel nostro database. \n \nQuesta app è riservata ai membri della NOI-Community. Se ne fai parte, controlla l\'indirizzo e-mail inserito e riprova. Se il problema persiste, invia un\'e-mail a community@noi.bz.it. \n \nVorresti entrare a far parte della NOI-Community? Clicca qui per le nostre offerte di lavoro. + L\'indirizzo e-mail inserito (%1$s) non è presente nel nostro database. \n \nQuesta app è riservata ai membri della NOI-Community. Se ne fai parte, controlla l\'indirizzo e-mail inserito e riprova. Se il problema persiste, invia un\'e-mail a community@noi.bz.it. \n \nVorresti entrare a far parte della NOI-Community? Clicca qui per le nostre offerte di lavoro. offerte di lavoro Ciao! La tua registrazione è andata a buon fine diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 98bb02a..9d59b5f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,7 +112,7 @@ Please do not edit this file by hand, use the export function from Google Sheet. Privacy policy Oh no! Oops, that didn\'t work! - The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! + The e-mail address you provided (%1$s) does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! here Hello! Your registration has been successful