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

GETEDUROAM-71: Improve username check and error message #94

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.focus.FocusState
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
Expand Down Expand Up @@ -69,7 +68,36 @@ fun UsernamePasswordDialog(
}

val keyboardController = LocalSoftwareKeyboardController.current
val requiredSuffixError = requiredSuffix?.let { stringResource(id = R.string.username_password_error_required_suffix, it) }
val requiredSuffixError = requiredSuffix?.let {
val suffix = if (enforceRequiredSuffix) "@$it" else it
stringResource(id = R.string.username_password_error_required_suffix, suffix)
}

fun checkLoginDetailsValidity() {
if (!requiredSuffix.isNullOrEmpty() && !username.endsWith(requiredSuffix, ignoreCase = false)) {
if (enforceRequiredSuffix) {
usernameError = requiredSuffixError
} else {
val usernameAndSuffix = "$username@$requiredSuffix"
if (usernameAndSuffix.endsWith(requiredSuffix, ignoreCase = false)) {
usernameError = requiredSuffixError
} else {
logIn(usernameAndSuffix, password)
}
}
} else if (!requiredSuffix.isNullOrEmpty() &&
enforceRequiredSuffix &&
!username.endsWith("@$requiredSuffix", ignoreCase = false)) {
// Username does end with the suffix, but it has a subdomain. When enforcing the username (InnerIdentityHint == true),
// this is not allowed, and we need to show the same error
usernameError = requiredSuffixError
} else {
usernameError = null
logIn(username, password)
}
keyboardController?.hide()
}

Column {
Surface(
shape = MaterialTheme.shapes.medium
Expand Down Expand Up @@ -136,11 +164,7 @@ fun UsernamePasswordDialog(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, autoCorrect = false, imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
if (username.isNotBlank() && password.isNotBlank()) {
logIn(username, password)
} else {
keyboardController?.hide()
}
checkLoginDetailsValidity()
}
),
label = {
Expand Down Expand Up @@ -179,27 +203,7 @@ fun UsernamePasswordDialog(
Spacer(modifier = Modifier.size(8.dp))
Button(
onClick = {
if (!requiredSuffix.isNullOrEmpty() && !username.endsWith(requiredSuffix, ignoreCase = false)) {
if (enforceRequiredSuffix) {
usernameError = requiredSuffixError
} else {
val usernameAndSuffix = "$username@$requiredSuffix"
if (usernameAndSuffix.endsWith(requiredSuffix, ignoreCase = false)) {
usernameError = requiredSuffixError
} else {
logIn(usernameAndSuffix, password)
}
}
} else if (!requiredSuffix.isNullOrEmpty() &&
enforceRequiredSuffix &&
!username.endsWith("@$requiredSuffix", ignoreCase = false)) {
// Username does end with the suffix, but it has a subdomain. When enforcing the username (InnerIdentityHint == true),
// this is not allowed, and we need to show the same error
usernameError = requiredSuffixError
} else {
usernameError = null
logIn(username, password)
}
checkLoginDetailsValidity()
},
enabled = username.isNotBlank() && password.isNotBlank()
) {
Expand Down
14 changes: 6 additions & 8 deletions android/app/src/main/res/values-cy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<string name="welcome">Croeso</string>
<string name="organizations_no_results">Methu dod o hyd i unrhyw sefydliadau</string>
<string name="organization_search_text">Chwiliwch am eich sefydliad</string>
<string name="institutions_choose_one">Dewiswch y sefydliad yr ydych am gysylltu ag ef.</string>
<string name="institutions_choose_one">Dewiswch y sefydliad yr ydych am cysylltu ag ef.</string>
<string name="profiles_title">Proffiliau</string>
<string name="profiles_header">Dewiswch proffil</string>
<string name="configuration_progress">Sefydlu cysylltiad Wi-Fi</string>
<string name="configuration_waiting_for_user_credentials">Aros am fanylion y defnyddiwr…</string>
<string name="configuration_android_10_notification_disclaimer">Mae Android 10 yn gofyn ichi dderbyn y rhwydweithiau Wi-Fi newydd trwy hysbysiad distaw. Gweler eich adran Hysbysiadau i gysylltu â\'r rhwydweithiau newydd.</string>
<string name="configuration_android_10_notification_disclaimer">Mae Android 10 yn gofyn ichi dderbyn y rhwydweithiau Wi-Fi newydd trwy hysbysiad distaw. Gweler eich adran Hysbysiadau i cysylltu â\'r rhwydweithiau newydd.</string>
<string name="configuration_success">Wi-Fi wedi\'i ffurfweddu</string>
<string name="configuration_logs">Negeseuon log:</string>
<string name="configuration_canceled">Canslwyd</string>
<string name="configuration_completed">Cwblhawyd</string>
<string name="login_dialog_title">Mae angen mewngofnodi</string>
<string name="login_dialog_text">Rhowch eich enw defnyddiwr a chyfrinair</string>
<string name="login_dialog_text">Rhowch eich enw defnyddiwr a cyfrinair</string>
<string name="login_dialog_username">Enw defnyddiwr</string>
<string name="login_dialog_password">Cyfrinair</string>
<string name="login_dialog_cancel">Canslo</string>
<string name="login_dialog_login">Mewngofnodi</string>
<string name="terms_of_use_dialog_title">Telerau defnyddio</string>
<string name="terms_of_use_dialog_text">Rhaid i chi gytuno i\'r telerau defnyddio cyn y gallwch ddefnyddio\'r rhwydwaith hwn</string>
<string name="terms_of_use_dialog_text">Rhaid i chi cytuno i\'r telerau defnyddio cyn y gallwch ddefnyddio\'r rhwydwaith hwn</string>
<string name="terms_of_use_dialog_agree">Cytuno</string>
<string name="terms_of_use_dialog_disagree">Anghytuno</string>

Expand All @@ -31,14 +31,13 @@
<string name="err_title_auth_failed">Methodd awdurdodiad</string>
<string name="err_msg_auth_failed">Dim cyflwr awdurdodi wedi\'i gadw - angen ail-awdurdodi.</string>
<string name="err_msg_auth_token_failed">Methodd cyfnewid cod tocyn awdurdodi.</string>
<string name="err_msg_auth_code_failed_arg">Methodd cyfnewid cod awdurdodi %s.</string>
<string name="err_msg_auth_code_failed_arg">Methodd cyfnewid cod awdurdodi: %s.</string>
<string name="err_title_generic_fail">Methu cwblhau\'r cais</string>
<string name="err_msg_generic_unexpected_with_arg">Gwall annisgwyl: %s, rhowch gynnig arall arni.</string>
<string name="err_msg_invalid_organization_id">ID sefydliad annilys. Methu parhau ar gyfer y sefydliad a ddewiswyd.</string>
<string name="err_msg_cannot_find_organization">Methu dod o hyd i sefydliad ag ID %s.</string>
<string name="err_msg_missing_eap_endpoint">Mae pwynt terfyn EAP ar goll o\'r proffil a ddewiswyd.</string>
<string name="err_msg_no_valid_provider">Ni chanfuwyd darparwr EAP dilys.</string>

<string name="oauth_title" tools:ignore="ExtraTranslation">Dilysu</string>
<string name="oauth_description" tools:ignore="ExtraTranslation">Dilyswch gyda\'ch cyfrif i noi eich ffurfweddiad Wi-Fi.</string>
<string name="oauth_processing" tools:ignore="ExtraTranslation">Prosesu...</string>
Expand All @@ -55,12 +54,11 @@
<string name="helpdesk_title">Desg helpu</string>

<string name="username_password_login_required">Angen mewngofnodi</string>
<string name="username_password_please_enter">Rhowch eich enw defnyddiwr a chyfrinair.</string>
<string name="username_password_please_enter">Rhowch eich enw defnyddiwr a cyfrinair.</string>
<string name="username_password_label_username">Enw defnyddiwr</string>
<string name="username_password_label_password">Cyfrinair</string>
<string name="username_password_button_cancel">Canslo</string>
<string name="username_password_button_log_in">Mewngofnodi</string>

<string name="username_password_placeholder_username_example_suffix">example.com</string>
<string name="username_password_placeholder_username_before_suffix">enw defnyddiwr</string>
<string name="username_password_accessibility_hide_password">Cuddio cyfrinair</string>
Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<string name="welcome">Üdvözlet</string>
<string name="organizations_no_results">Nem találom a szervezetet.</string>
<string name="organization_search_text">Intézmény keresés</string>
<string name="open_eap_config_file">.eap-config fájl megnyitása</string>
<string name="connect_to_server">Kapcsolódás ehhez: %s</string>
<string name="institutions_choose_one">Válaszd ki azt az intézményt amelyhez csatlakozol.</string>
<string name="profiles_title">Profilok</string>
<string name="profiles_header">Válaszd ki a profilt</string>
Expand All @@ -26,6 +28,8 @@
<string name="err_title_auth_unexpected_fail">Ismeretlen hiba</string>
<string name="err_msg_auth_init_fail">Az AppData inicializálása nem sikerült. Próbáld újra.</string>
<string name="err_msg_auth_init_fail_arg">Az AppData inicializálása nem sikerült. Hibaok: %s</string>
<string name="err_msg_auth_no_saved_configuration">Mentett konfiguráció hiányzik</string>
<string name="err_msg_auth_no_matching_auth_request">Autorizációs kérés nem található a visszatérési címhez</string>
<string name="err_title_auth_invalid">Érvénytelen jogosultság.</string>
<string name="err_msg_auth_invalid">Nem sikerült az azonosítás/belépés.</string>
<string name="err_title_auth_failed">Jogosultság ellenőrzés sikertelen.</string>
Expand All @@ -37,8 +41,10 @@
<string name="err_msg_invalid_organization_id">Érvénytelen intézmény azonosító. Nem lehetséges ezzel az intézménnyel továbblépni.</string>
<string name="err_msg_cannot_find_organization">Nem találok intézményt %s azonosítóval.</string>
<string name="err_msg_missing_eap_endpoint">A kiválasztott profilhoz nincsen EAP konfiguráció.</string>
<string name="err_msg_could_not_discover_profile_configuration">A profil konfigurációt nem sikerült megtalálni. Ellenőrizd az internetkapcsolatot és próbáld újra.</string>
<string name="err_msg_no_valid_provider">Nem találtam megfelelő EAP beállítást.</string>

<string name="err_msg_not_a_valid_eap_config_file">Ez az .eap-config fájl nem értelmezhető</string>
<string name="oauth_title" tools:ignore="ExtraTranslation">Azonosítás</string>
<string name="oauth_description" tools:ignore="ExtraTranslation">Lépj be az azonosítóddal, hogy be tudjuk állítani a WiFi-t</string>
<string name="oauth_processing" tools:ignore="ExtraTranslation">Egy pillanat...</string>
Expand All @@ -61,6 +67,7 @@
<string name="username_password_button_cancel">Törlés</string>
<string name="username_password_button_log_in">Belépés</string>

<string name="username_password_error_required_suffix">Felhasználónév végződjön a következőre: %s</string>
<string name="username_password_placeholder_username_example_suffix">example.com</string>
<string name="username_password_placeholder_username_before_suffix">felhasznaloinev</string>
<string name="username_password_accessibility_hide_password">Rejtsd el a jelszót</string>
Expand Down
13 changes: 11 additions & 2 deletions android/app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<string name="profiles_title">Profili</string>
<string name="profiles_header">Seleziona un profilo</string>
<string name="configuration_progress">Sto instaurando la connessione Wi-Fi</string>
<string name="configuration_waiting_for_user_credentials">In attesa delle credenziali dell\'utente...</string>
<string name="configuration_android_10_notification_disclaimer">Android 10 richiede l\'accettazione delle nuove reti Wi-Fi tramite una notifica silenziosa. Consulta la sezione notifiche per connetterti alle nuove reti.</string>
<string name="configuration_success">WiFi configurato</string>
<string name="configuration_logs">Messaggi di Log:</string>
<string name="configuration_canceled">Annullato</string>
Expand Down Expand Up @@ -36,7 +38,6 @@
<string name="err_msg_cannot_find_organization">Impossibile trovare l\'organizzazione con ID %s.</string>
<string name="err_msg_missing_eap_endpoint">Nel profilo selezionato manca l\'endpoint EAP.</string>
<string name="err_msg_no_valid_provider">Non è stato trovato alcun provider EAP valido.</string>

<string name="oauth_title" tools:ignore="ExtraTranslation">Autenticare</string>
<string name="oauth_description" tools:ignore="ExtraTranslation">Autenticati con il tuo account per ottenere la configurazione wifi.</string>
<string name="oauth_processing" tools:ignore="ExtraTranslation">Processando...</string>
Expand All @@ -58,7 +59,6 @@
<string name="username_password_label_password">Password</string>
<string name="username_password_button_cancel">Annulla</string>
<string name="username_password_button_log_in">Accedi</string>

<string name="username_password_placeholder_username_example_suffix">example.com</string>
<string name="username_password_placeholder_username_before_suffix">nome utente</string>
<string name="username_password_accessibility_hide_password">Nascondi password</string>
Expand All @@ -67,4 +67,13 @@
<string name="notification_channel_name">Promemoria di riconfigurazione</string>
<string name="notification_title">Riconfigura %s</string>
<string name="notification_message">Mancano %1$d giorni alla scadenza del tuo profilo %2$s, clicca per riconfigurarlo</string>

<string name="passphrase_dialog_title">Inserisci la passphrase</string>
<string name="passphrase_dialog_message">Questo profilo richiede una passphrase</string>
<string name="passphrase_dialog_label_passphrase">Passphrase</string>
<string name="passphrase_dialog_button_cancel">Annulla</string>
<string name="passphrase_dialog_button_enter">Invio</string>
<string name="passphrase_dialog_incorrect_passphrase">La passphrase che hai inserito non è corretta!</string>
<string name="passphrase_accessibility_hide_passphrase">Nascondi la passphrase</string>
<string name="passphrase_accessibility_show_passphrase">Visualizza la passphrase</string>
</resources>
7 changes: 7 additions & 0 deletions android/app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<string name="welcome">Welkom</string>
<string name="organizations_no_results">Geen organisaties gevonden</string>
<string name="organization_search_text">Zoek jouw organisatie</string>
<string name="open_eap_config_file">Open .eap-config bestand</string>
<string name="connect_to_server">Verbinden met %s</string>
<string name="institutions_choose_one">Kies de instelling waarmee je verbinding wil maken.</string>
<string name="profiles_title">Profielen</string>
<string name="profiles_header">Kies een profiel</string>
Expand All @@ -26,6 +28,8 @@
<string name="err_title_auth_unexpected_fail">Onverwachte fout</string>
<string name="err_msg_auth_init_fail">Kan AppData niet initialiseren. Probeer het opnieuw.</string>
<string name="err_msg_auth_init_fail_arg">Kan AppData niet initialiseren. Reden: %s</string>
<string name="err_msg_auth_no_saved_configuration">Opgeslagen configuratie niet gevonden</string>
<string name="err_msg_auth_no_matching_auth_request">Geen authorisatieverzoek voor redirect URI gevonden</string>
<string name="err_title_auth_invalid">Authorisatie ongeldig</string>
<string name="err_msg_auth_invalid">Geen geldige authenticatie ontvangen.</string>
<string name="err_title_auth_failed">Authorisatie mislukt</string>
Expand All @@ -37,7 +41,9 @@
<string name="err_msg_invalid_organization_id">Onjuiste organisatie id. Kan niet doorgaan met de geselecteerde organisatie.</string>
<string name="err_msg_cannot_find_organization">Kan organisatie met id %s niet vinden.</string>
<string name="err_msg_missing_eap_endpoint">Geselecteerde profiel mist het EAP endpoint.</string>
<string name="err_msg_could_not_discover_profile_configuration">Kan de profielconfiguratie niet vinden. Controleer je verbinding en probeer het opnieuw.</string>
<string name="err_msg_no_valid_provider">Geen geldige EAP-provider gevonden.</string>
<string name="err_msg_not_a_valid_eap_config_file">Geen geldig .eap-config bestand.</string>

<string name="oauth_title" tools:ignore="ExtraTranslation">Authenticeer</string>
<string name="oauth_description" tools:ignore="ExtraTranslation">Authenticeer met uw account om uw wifi-configuratie te verkrijgen.</string>
Expand All @@ -60,6 +66,7 @@
<string name="username_password_label_password">Wachtwoord</string>
<string name="username_password_button_cancel">Annuleren</string>
<string name="username_password_button_log_in">Log in</string>
<string name="username_password_error_required_suffix">Gebruikersnaam moet eindigen op: %s</string>

<string name="username_password_placeholder_username_example_suffix">voorbeeld.com</string>
<string name="username_password_placeholder_username_before_suffix">gebruikersnaam</string>
Expand Down
Loading
Loading