Prevent user from connecting the same account multiple times

This commit is contained in:
Sylvain Berfini 2025-03-12 13:31:40 +01:00
parent 17d46ed68c
commit 68f864f387
4 changed files with 22 additions and 0 deletions

View file

@ -181,6 +181,16 @@ open class AccountLoginViewModel
return@postOnCoreThread
}
val accounts = core.accountList
val found = accounts.find {
it.params.identityAddress?.weakEqual(identityAddress) == true
}
if (found != null) {
Log.w("$TAG An account with the same identity address [${identityAddress.asStringUriOnly()}] already exists, do not add it again!")
showRedToast(R.string.assistant_account_login_already_connected_error, R.drawable.warning_circle)
return@postOnCoreThread
}
val user = identityAddress.username
if (user == null) {
Log.e(

View file

@ -203,6 +203,16 @@ class ThirdPartySipAccountLoginViewModel
return@postOnCoreThread
}
val accounts = core.accountList
val found = accounts.find {
it.params.identityAddress?.weakEqual(identityAddress) == true
}
if (found != null) {
Log.w("$TAG An account with the same identity address [${identityAddress.asStringUriOnly()}] already exists, do not add it again!")
showRedToast(R.string.assistant_account_login_already_connected_error, R.drawable.warning_circle)
return@postOnCoreThread
}
newlyCreatedAuthInfo = Factory.instance().createAuthInfo(
user,
userId,

View file

@ -106,6 +106,7 @@
<string name="assistant_login_using_single_sign_on">Single sign on</string>
<string name="assistant_login_cant_parse_address_toast">Adresse SIP invalide</string>
<string name="assistant_login_address_without_username_toast">L\'adresse SIP ne contient pas de nom d\'utilisateur !</string>
<string name="assistant_account_login_already_connected_error">Le compte est déjà connecté</string>
<string name="assistant_no_account_yet">Pas encore de compte ?</string>
<string name="assistant_account_register">Créer un compte</string>
<string name="assistant_account_creation_sms_confirmation_title">Confirmez votre numéro</string>

View file

@ -145,6 +145,7 @@
<string name="assistant_login_using_single_sign_on">Single sign on</string>
<string name="assistant_login_cant_parse_address_toast">SIP address is invalid!</string>
<string name="assistant_login_address_without_username_toast">SIP address doesn\'t contains a username!</string>
<string name="assistant_account_login_already_connected_error">Account already exists</string>
<string name="assistant_no_account_yet">No account yet?</string>
<string name="assistant_account_register">Register</string>
<string name="assistant_account_creation_sms_confirmation_title">Confirm your phone number</string>