From 1e44fc4dc968920bdcba56a13b8a8a180b0f7663 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 19 Nov 2026 10:07:03 +0800 Subject: [PATCH] Return a business error when assigning roles without a current user --- .../Abp/Identity/IdentityUserAppService.cs | 14 ++++- .../Volo/Abp/Identity/IdentityErrorCodes.cs | 1 + .../Volo/Abp/Identity/Localization/ar.json | 1 + .../Volo/Abp/Identity/Localization/cs.json | 1 + .../Volo/Abp/Identity/Localization/de.json | 1 + .../Volo/Abp/Identity/Localization/el.json | 1 + .../Volo/Abp/Identity/Localization/en-GB.json | 1 + .../Volo/Abp/Identity/Localization/en.json | 1 + .../Volo/Abp/Identity/Localization/es.json | 1 + .../Volo/Abp/Identity/Localization/fa.json | 1 + .../Volo/Abp/Identity/Localization/fi.json | 1 + .../Volo/Abp/Identity/Localization/fr.json | 1 + .../Volo/Abp/Identity/Localization/he.json | 1 + .../Volo/Abp/Identity/Localization/hi.json | 1 + .../Volo/Abp/Identity/Localization/hr.json | 1 + .../Volo/Abp/Identity/Localization/hu.json | 1 + .../Volo/Abp/Identity/Localization/is.json | 1 + .../Volo/Abp/Identity/Localization/it.json | 1 + .../Volo/Abp/Identity/Localization/ko.json | 1 + .../Volo/Abp/Identity/Localization/nl.json | 1 + .../Volo/Abp/Identity/Localization/pl-PL.json | 1 + .../Volo/Abp/Identity/Localization/pt-BR.json | 1 + .../Volo/Abp/Identity/Localization/pt.json | 1 + .../Volo/Abp/Identity/Localization/ro-RO.json | 1 + .../Volo/Abp/Identity/Localization/ru.json | 1 + .../Volo/Abp/Identity/Localization/sk.json | 1 + .../Volo/Abp/Identity/Localization/sl.json | 1 + .../Volo/Abp/Identity/Localization/sv.json | 1 + .../Volo/Abp/Identity/Localization/tr.json | 1 + .../Volo/Abp/Identity/Localization/vi.json | 1 + .../Abp/Identity/Localization/zh-Hans.json | 1 + .../Abp/Identity/Localization/zh-Hant.json | 1 + .../Identity/IdentityUserAppService_Tests.cs | 59 +++++++++++++++++++ 33 files changed, 102 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 23499937f5..4ce6fbf72a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -79,7 +79,7 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe } else { - var currentUserRoles = await UserManager.GetRolesAsync(await UserManager.GetByIdAsync(CurrentUser.GetId())); + var currentUserRoles = await UserManager.GetRolesAsync(await UserManager.GetByIdAsync(GetCurrentUserIdForRoleAssignment())); list = (await RoleRepository.GetListAsync(currentUserRoles)).OrderBy(x => x.Name).ToList(); } @@ -228,7 +228,7 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe var targetCurrentRoleSet = (await UserManager.GetRolesAsync(user)).ToHashSet(StringComparer.OrdinalIgnoreCase); - var operatorUser = await UserManager.GetByIdAsync(CurrentUser.GetId()); + var operatorUser = await UserManager.GetByIdAsync(GetCurrentUserIdForRoleAssignment()); var operatorOwnRoleSet = (await UserManager.GetRolesAsync(operatorUser)).ToHashSet(StringComparer.OrdinalIgnoreCase); var inputRoleNameSet = new HashSet(inputRoleNames ?? Array.Empty(), StringComparer.OrdinalIgnoreCase); @@ -246,4 +246,14 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe { return Task.FromResult(CurrentUser.IsInRole(AbpRoleConsts.AdminRoleName)); } + + protected virtual Guid GetCurrentUserIdForRoleAssignment() + { + if (!CurrentUser.Id.HasValue) + { + throw new BusinessException(IdentityErrorCodes.UserContextRequiredForRoleAssignment); + } + + return CurrentUser.Id.Value; + } } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityErrorCodes.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityErrorCodes.cs index 0495679a5f..72b12ef4a6 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityErrorCodes.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityErrorCodes.cs @@ -15,4 +15,5 @@ public static class IdentityErrorCodes public const string ClaimNameExist = "Volo.Abp.Identity:010021"; public const string CanNotUpdateStaticClaimType = "Volo.Abp.Identity:010022"; public const string CanNotDeleteStaticClaimType = "Volo.Abp.Identity:010023"; + public const string UserContextRequiredForRoleAssignment = "Volo.Abp.Identity:010024"; } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json index 2d7450ae44..443ac3c268 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "الاسم {0} موجود بالفعل.", "Volo.Abp.Identity:010022": "لا يمكن تحديث نوع المطابقة.", "Volo.Abp.Identity:010023": "لا يمكن حذف نوع المطابقة.", + "Volo.Abp.Identity:010024": "يلزم وجود هوية مستخدم لعرض الأدوار القابلة للتعيين أو تغيير أدوار المستخدم.", "Identity.OrganizationUnit.MaxUserMembershipCount": "العدد الأقصى المسموح به لعضوية الوحدة التنظيمية للمستخدم", "ThisUserIsNotActiveMessage": "هذا المستخدم غير نشط.", "Permission:IdentityManagement": "إدارة الهوية", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json index b5613814e1..f99d7f66de 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Název '{0}' již existuje.", "Volo.Abp.Identity:010022": "Nelze aktualizovat statický typ deklarace.", "Volo.Abp.Identity:010023": "Nelze smazat statický typ deklarace.", + "Volo.Abp.Identity:010024": "K zobrazení přiřaditelných rolí nebo ke změně rolí uživatele je vyžadována identita uživatele.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximální povolený počet členů organizační jednotky pro uživatele", "ThisUserIsNotActiveMessage": "Tento uživatel není aktivní.", "Permission:IdentityManagement": "Správa identit", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json index 8118160f2a..057732691a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Der Name existiert bereits {0}", "Volo.Abp.Identity:010022": "Der Name kann nicht aktualisiert werden.", "Volo.Abp.Identity:010023": "Der Name kann nicht gelöscht werden.", + "Volo.Abp.Identity:010024": "Zum Anzeigen zuweisbarer Rollen oder zum Ändern von Benutzerrollen ist eine Benutzeridentität erforderlich.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximal zulässige Anzahl an Mitgliedschaften in Organisationseinheiten für einen Benutzer", "ThisUserIsNotActiveMessage": "Dieser Benutzer ist nicht aktiv.", "Permission:IdentityManagement": "Identitätsverwaltung", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json index 1a1e10714d..6732c59530 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json @@ -80,6 +80,7 @@ "Volo.Abp.Identity:010021": "Το όνομα '{0}' υπάρχει ήδη.", "Volo.Abp.Identity:010022": "Δεν μπορείτε να ενημερώσετε ένα στατικό τύπο δήλωσης.", "Volo.Abp.Identity:010023": "Δεν μπορείτε να διαγράψετε ένα στατικό τύπο δήλωσης.", + "Volo.Abp.Identity:010024": "Απαιτείται ταυτότητα χρήστη για την προβολή των ρόλων που μπορούν να ανατεθούν ή την αλλαγή ρόλων χρήστη.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Μέγιστος επιτρεπόμενος αριθμός μελών μονάδας οργανισμού για έναν χρήστη", "ThisUserIsNotActiveMessage": "Αυτός ο χρήστης δεν είναι ενεργός.", "Permission:IdentityManagement": "Διαχείριση ταυτότητας", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json index 3318b5cf19..5145858441 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json @@ -80,6 +80,7 @@ "Volo.Abp.Identity:010021": "Name exist: '{0}'", "Volo.Abp.Identity:010022": "Can not update a static ClaimType.", "Volo.Abp.Identity:010023": "Can not delete a static ClaimType.", + "Volo.Abp.Identity:010024": "A user identity is required to view assignable roles or change user roles.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximum allowed organisation unit membership count for a user", "Permission:IdentityManagement": "Identity management", "Permission:RoleManagement": "Role management", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json index 3a6e9e18ca..6fd8cd886b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Name exist: '{0}'.", "Volo.Abp.Identity:010022": "Can not update a static ClaimType.", "Volo.Abp.Identity:010023": "Can not delete a static ClaimType.", + "Volo.Abp.Identity:010024": "A user identity is required to view assignable roles or change user roles.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximum allowed organization unit membership count for a user", "ThisUserIsNotActiveMessage": "This user is not active.", "Permission:IdentityManagement": "Identity management", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json index afc75eec4a..908665e571 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Ya existe un con el nombre '{0}'", "Volo.Abp.Identity:010022": "No se puede actualizar un tipo de reclamación estática.", "Volo.Abp.Identity:010023": "No se puede borrar un tipo de reclamación estática.", + "Volo.Abp.Identity:010024": "Se requiere una identidad de usuario para ver los roles asignables o cambiar los roles de usuario.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Número máximo de unidades organizativas por usuario", "ThisUserIsNotActiveMessage": "Este usuario no está activo.", "Permission:IdentityManagement": "Gestión de identidades", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json index e6229c5a4d..25fb302395 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "نام {0} قبلاً استفاده گردیده است.", "Volo.Abp.Identity:010022": "نمی توان نام نقش/وظیفه را تغییر داد.", "Volo.Abp.Identity:010023": "نمی توان نقش/وظیفه را حذف کرد.", + "Volo.Abp.Identity:010024": "برای مشاهده نقشها و وظایف قابل تخصیص یا تغییر نقشها و وظایف کاربر، هویت کاربر لازم است.", "Identity.OrganizationUnit.MaxUserMembershipCount": "حداکثر تعداد مجاز عضویت در یک واحد سازمان برای یک کاربر", "ThisUserIsNotActiveMessage": "این کاربر غیرفعال میباشد.", "Permission:IdentityManagement": "مدیریت هویت", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json index 2adeb4b309..816fbb6547 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "{0} on jo olemassa.", "Volo.Abp.Identity:010022": "Staattista väittämätunnusta ei voi päivittää.", "Volo.Abp.Identity:010023": "Staattista väittämätunnusta ei voi poistaa.", + "Volo.Abp.Identity:010024": "Käyttäjäidentiteetti vaaditaan määritettävissä olevien roolien tarkasteluun tai käyttäjän roolien muuttamiseen.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Suurin sallittu organisaatioyksikön jäsenmäärä käyttäjälle", "ThisUserIsNotActiveMessage": "Tämä käyttäjä ei ole aktiivinen.", "Permission:IdentityManagement": "Identiteetin hallinta", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json index 9028def61b..41485b7eca 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Le nom '{0}' existe déjà.", "Volo.Abp.Identity:010022": "Vous ne pouvez pas modifier un type de revendication statique.", "Volo.Abp.Identity:010023": "Vous ne pouvez pas supprimer un type de revendication statique.", + "Volo.Abp.Identity:010024": "Une identité d'utilisateur est requise pour afficher les rôles attribuables ou modifier les rôles des utilisateurs.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Nombre maximal d’adhésions autorisées à l’unité d’organisation pour un utilisateur", "ThisUserIsNotActiveMessage": "Cet utilisateur n'est pas actif.", "Permission:IdentityManagement": "Gestion de l’identité", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/he.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/he.json index 2e859aa045..914f28c33a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/he.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/he.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "השם כבר קיים: '{0}'.", "Volo.Abp.Identity:010022": "אי אפשר לעדכן סוג טענה (ClaimType) סטטי.", "Volo.Abp.Identity:010023": "אי אפשר למחוק סוג טענה (ClaimType) סטטי.", + "Volo.Abp.Identity:010024": "נדרשת זהות משתמש כדי להציג תפקידים הניתנים להקצאה או לשנות תפקידי משתמש.", "Identity.OrganizationUnit.MaxUserMembershipCount": "המספר המרבי של יחידות ארגוניות שמשתמש יכול להשתייך אליהן", "ThisUserIsNotActiveMessage": "משתמש זה אינו פעיל.", "Permission:IdentityManagement": "ניהול זהויות", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json index 976610c38d..c90938ea66 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "नाम '{0}' पहले से ही लिया गया है।", "Volo.Abp.Identity:010022": "स्थैतिक भूमिकाओं का नाम नहीं बदला जा सकता है।", "Volo.Abp.Identity:010023": "स्थैतिक भूमिकाओं को हटाया नहीं जा सकता।", + "Volo.Abp.Identity:010024": "असाइन की जा सकने वाली भूमिकाएँ देखने या उपयोगकर्ता की भूमिकाएँ बदलने के लिए उपयोगकर्ता पहचान आवश्यक है।", "Identity.OrganizationUnit.MaxUserMembershipCount": "उपयोगकर्ता के लिए अधिकतम अनुमत संगठन इकाई सदस्यता गणना", "ThisUserIsNotActiveMessage": "यह उपयोगकर्ता सक्रिय नहीं है।", "Permission:IdentityManagement": "पहचान प्रबंधन", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json index 6fa68f1102..554016c2ab 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Naziv '{0}' već postoji.", "Volo.Abp.Identity:010022": "Ne možete ažurirati statički tip deklaracije.", "Volo.Abp.Identity:010023": "Ne možete izbrisati statički tip deklaracije.", + "Volo.Abp.Identity:010024": "Za pregled uloga koje se mogu dodijeliti ili promjenu uloga korisnika potreban je identitet korisnika.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maksimalni dopušteni broj članstva u organizacijskoj jedinici za korisnika", "ThisUserIsNotActiveMessage": "Ovaj korisnik nije aktivan.", "Permission:IdentityManagement": "Upravljanje identitetom", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json index 4891880abb..7e9cf444f0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "'{0}' nevű már létezik.", "Volo.Abp.Identity:010022": "Nem lehet frissíteni a statikus jogosultság típusát.", "Volo.Abp.Identity:010023": "Nem lehet törölni a statikus jogosultság típusát.", + "Volo.Abp.Identity:010024": "A hozzárendelhető szerepkörök megtekintéséhez vagy a felhasználói szerepkörök módosításához felhasználói identitás szükséges.", "Identity.OrganizationUnit.MaxUserMembershipCount": "A maximálisan megengedett szervezeti egység tagsági szám egy felhasználó számára", "ThisUserIsNotActiveMessage": "Ez a felhasználó nem aktív.", "Permission:IdentityManagement": "Identitáskezelés", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json index a934b3235e..de5babeb73 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Nafnið '{0}' er þegar í notkun.", "Volo.Abp.Identity:010022": "Ekki er hægt að breyta static hlutverk.", "Volo.Abp.Identity:010023": "Ekki er hægt að eyða static hlutverkum.", + "Volo.Abp.Identity:010024": "Notandaauðkenni er nauðsynlegt til að skoða hlutverk sem hægt er að úthluta eða breyta hlutverkum notanda.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Hámarks leyfileg fjöldi aðildar að skipulagseiningu fyrir notanda", "ThisUserIsNotActiveMessage": "Þessi notandi er ekki virkur.", "Permission:IdentityManagement": "Auðkenninga umsjón", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json index 869392ac23..9da189a234 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Il nome '{0}' è già in uso.", "Volo.Abp.Identity:010022": "Non puoi modificare il tipo di richiesta statica.", "Volo.Abp.Identity:010023": "Non puoi eliminare il tipo di richiesta statica.", + "Volo.Abp.Identity:010024": "È necessaria un'identità utente per visualizzare i ruoli assegnabili o modificare i ruoli dell'utente.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Numero massimo consentito di membri dell'unità organizzativa per un utente", "ThisUserIsNotActiveMessage": "Questo utente non è attivo.", "Permission:IdentityManagement": "Gestione identità", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ko.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ko.json index a46c0434fd..2264470add 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ko.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ko.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "이름이 이미 존재합니다: '{0}'.", "Volo.Abp.Identity:010022": "정적 클레임 유형은 업데이트할 수 없습니다.", "Volo.Abp.Identity:010023": "정적 클레임 유형은 삭제할 수 없습니다.", + "Volo.Abp.Identity:010024": "할당 가능한 역할을 조회하거나 사용자 역할을 변경하려면 사용자 ID가 필요합니다.", "Identity.OrganizationUnit.MaxUserMembershipCount": "사용자에게 허용되는 최대 조직 단위 멤버십 수", "ThisUserIsNotActiveMessage": "이 사용자는 활성 상태가 아닙니다.", "Permission:IdentityManagement": "ID 관리", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json index daa3f8b129..c812d82212 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Er bestaat al een met de naam '{0}'.", "Volo.Abp.Identity:010022": "Kan de naam van een statische claim niet wijzigen.", "Volo.Abp.Identity:010023": "Kan de naam van een statische claim niet verwijderen.", + "Volo.Abp.Identity:010024": "Er is een gebruikersidentiteit vereist om toewijsbare rollen te bekijken of gebruikersrollen te wijzigen.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximaal toegestande aantal lidmaatschappen van organisatie-eenheden voor een gebruiker", "ThisUserIsNotActiveMessage": "Deze gebruiker is niet actief.", "Permission:IdentityManagement": "Identiteitsbeheer", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json index 0f222bf42c..fc958884cb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Nazwa '{0}' już istnieje.", "Volo.Abp.Identity:010022": "Nie można zmienić typu statycznej deklaracji.", "Volo.Abp.Identity:010023": "Nie można usunąć typu statycznej deklaracji.", + "Volo.Abp.Identity:010024": "Do wyświetlania ról możliwych do przypisania lub zmiany ról użytkownika wymagana jest tożsamość użytkownika.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maksymalna dozwolona liczba członków jednostki organizacyjnej dla użytkownika", "ThisUserIsNotActiveMessage": "Ten użytkownik nie jest aktywny.", "Permission:IdentityManagement": "Zarządzanie tożsamością", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json index 76ab7ea4cb..3ed8020557 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Já existe um(a) {0} com o nome.", "Volo.Abp.Identity:010022": "Não é possível alterar o tipo de declaração estática.", "Volo.Abp.Identity:010023": "Não é possível excluir o tipo de declaração estática.", + "Volo.Abp.Identity:010024": "É necessária uma identidade de usuário para visualizar os perfis atribuíveis ou alterar os perfis do usuário.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Contagem máxima permitida de membros da unidade organizacional para um usuário", "ThisUserIsNotActiveMessage": "Este usuário não está ativo.", "Permission:IdentityManagement": "Acessos", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt.json index cfa9160cdc..caa721a04a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "O nome já existe: '{0}'.", "Volo.Abp.Identity:010022": "Não é possível atualizar um tipo de claim estático.", "Volo.Abp.Identity:010023": "Não é possível eliminar um tipo de claim estático.", + "Volo.Abp.Identity:010024": "É necessária uma identidade de utilizador para ver os perfis atribuíveis ou alterar os perfis do utilizador.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Número máximo de unidades organizacionais permitido para um utilizador", "ThisUserIsNotActiveMessage": "Este utilizador não está ativo.", "Permission:IdentityManagement": "Gestão de identidade", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json index f9c624a977..d07af51405 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Numele '{0}' este deja luat.", "Volo.Abp.Identity:010022": "Nu poate fi schimbată tipul de declaraţie statică.", "Volo.Abp.Identity:010023": "Nu poate fi ştersă declaraţia statică.", + "Volo.Abp.Identity:010024": "Este necesară o identitate de utilizator pentru a vizualiza rolurile care pot fi atribuite sau pentru a modifica rolurile utilizatorului.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Numărul maxim de unităţi organizaţionale permise pentru un utilizator", "ThisUserIsNotActiveMessage": "Acest utilizator nu este activ.", "Permission:IdentityManagement": "Administrare identităţii", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json index 5056ad34f2..4863946277 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Имя '{0}' уже существует.", "Volo.Abp.Identity:010022": "Невозможно изменить тип статической декларации.", "Volo.Abp.Identity:010023": "Невозможно удалить тип статической декларации.", + "Volo.Abp.Identity:010024": "Для просмотра назначаемых ролей или изменения ролей пользователя требуется удостоверение пользователя.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Максимально допустимое количество членов организационного подразделения для пользователя", "ThisUserIsNotActiveMessage": "Этот пользователь не активен.", "Permission:IdentityManagement": "Управление идентификацией", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json index 1609ec94db..f819c7af53 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Názov '{0}' sa už používa.", "Volo.Abp.Identity:010022": "Nie je možné zmeniť typ statického oprávnenia.", "Volo.Abp.Identity:010023": "Nie je možné odstrániť typ statického oprávnenia.", + "Volo.Abp.Identity:010024": "Na zobrazenie priraditeľných rolí alebo zmenu rolí používateľa sa vyžaduje identita používateľa.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Maximálny povolený počet členov organizačnej jednotky pre používateľa", "ThisUserIsNotActiveMessage": "Tento používateľ nie je aktívny.", "Permission:IdentityManagement": "Správa identít", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json index 98c3b8c4bf..9237a8dcc9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Naziv '{0}' že obstaja.", "Volo.Abp.Identity:010022": "Ne morete spremeniti tipa statične deklaracije.", "Volo.Abp.Identity:010023": "Ne morete izbrisati tipa statične deklaracije.", + "Volo.Abp.Identity:010024": "Za ogled vlog, ki jih je mogoče dodeliti, ali spreminjanje vlog uporabnika je potrebna identiteta uporabnika.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Največje dovoljeno število članov v organizacijski enoti za uporabnika", "ThisUserIsNotActiveMessage": "Ta uporabnik ni aktiven.", "Permission:IdentityManagement": "Upravljanje identitet", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sv.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sv.json index 394c4d0a7e..6460eaf9f3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sv.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sv.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Namn finns: '{0}'.", "Volo.Abp.Identity:010022": "Kan inte ändra statiskt område.", "Volo.Abp.Identity:010023": "Kan inte ta bort statiskt område.", + "Volo.Abp.Identity:010024": "En användaridentitet krävs för att visa tilldelningsbara roller eller ändra användarroller.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Högsta tillåtna antal medlemskap i organisationsenheter för en användare", "ThisUserIsNotActiveMessage": "Den här användaren är inte aktiv.", "Permission:IdentityManagement": "Identitetshantering", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json index 8e8d678f0a..62ce799829 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "{0} isminde bir birim zaten var.", "Volo.Abp.Identity:010022": "Bir statik izin tipi değiştirilemez.", "Volo.Abp.Identity:010023": "Bir statik izin tipi silinemez.", + "Volo.Abp.Identity:010024": "Atanabilir rolleri görüntülemek veya kullanıcı rollerini değiştirmek için bir kullanıcı kimliği gereklidir.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Bir kullanıcı için izin verilen en fazla organizasyon birimi sayısı", "ThisUserIsNotActiveMessage": "Bu kullanıcı aktif değil.", "Permission:IdentityManagement": "Kimlik yönetimi", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json index 46f26b0040..eceb01ba34 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "Tên '{0}' đã tồn tại.", "Volo.Abp.Identity:010022": "Không thể thay đổi kiểu của phát biểu tĩnh.", "Volo.Abp.Identity:010023": "Không thể xóa phát biểu tĩnh.", + "Volo.Abp.Identity:010024": "Cần có danh tính người dùng để xem các vai trò có thể gán hoặc thay đổi vai trò của người dùng.", "Identity.OrganizationUnit.MaxUserMembershipCount": "Số lượng thành viên đơn vị tổ chức tối đa được phép cho một người dùng", "ThisUserIsNotActiveMessage": "Người dùng này không hoạt động.", "Permission:IdentityManagement": "Quản lý danh tính", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json index 34045a010b..19b3bf7014 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "名称:'{0}' 已存在", "Volo.Abp.Identity:010022": "不能更改静态声明的类型。", "Volo.Abp.Identity:010023": "不能删除静态声明的类型。", + "Volo.Abp.Identity:010024": "查看可分配的角色或更改用户角色需要用户身份。", "Identity.OrganizationUnit.MaxUserMembershipCount": "组织单位最大允许的成员资格计数", "ThisUserIsNotActiveMessage": "该用户不可用。", "Permission:IdentityManagement": "身份标识管理", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json index c54f18c4b2..5219f24e93 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json @@ -81,6 +81,7 @@ "Volo.Abp.Identity:010021": "名稱 '{0}' 已存在.", "Volo.Abp.Identity:010022": "無法更改靜態宣告的類型.", "Volo.Abp.Identity:010023": "無法刪除靜態宣告的類型.", + "Volo.Abp.Identity:010024": "檢視可指派的角色或變更使用者角色需要使用者身分。", "Identity.OrganizationUnit.MaxUserMembershipCount": "允許一個使用者至多可隸屬在幾個組織單位", "ThisUserIsNotActiveMessage": "該用戶不可用.", "Permission:IdentityManagement": "身份識別管理", diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs index ff3c503657..f689fdabd9 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs @@ -406,6 +406,65 @@ public class IdentityUserAppService_Tests : AbpIdentityApplicationTestBase roleNames.ShouldNotContain("manager"); } + [Fact] + public async Task UpdateRolesAsync_Should_Throw_When_There_Is_No_Current_User() + { + using (_currentPrincipalAccessor.Change(new Claim(AbpClaimTypes.ClientId, "test-client"))) + { + var exception = await Assert.ThrowsAsync(async () => + { + await _userAppService.UpdateRolesAsync( + _testData.UserDavidId, + new IdentityUserUpdateRolesDto + { + RoleNames = new[] { "supporter" } + } + ); + }); + + exception.Code.ShouldBe(IdentityErrorCodes.UserContextRequiredForRoleAssignment); + } + + var roleNames = await _userRepository.GetRoleNamesAsync(_testData.UserDavidId); + roleNames.ShouldNotContain("supporter"); + } + + [Fact] + public async Task CreateAsync_With_Roles_Should_Throw_When_There_Is_No_Current_User() + { + var input = new IdentityUserCreateDto + { + UserName = Guid.NewGuid().ToString(), + Email = CreateRandomEmail(), + Password = "123qwE4r*", + RoleNames = new[] { "supporter" } + }; + + using (_currentPrincipalAccessor.Change(new Claim(AbpClaimTypes.ClientId, "test-client"))) + { + var exception = await Assert.ThrowsAsync(async () => + { + await _userAppService.CreateAsync(input); + }); + + exception.Code.ShouldBe(IdentityErrorCodes.UserContextRequiredForRoleAssignment); + } + } + + [Fact] + public async Task GetAssignableRolesAsync_Should_Throw_When_There_Is_No_Current_User() + { + using (_currentPrincipalAccessor.Change(new Claim(AbpClaimTypes.ClientId, "test-client"))) + { + var exception = await Assert.ThrowsAsync(async () => + { + await _userAppService.GetAssignableRolesAsync(); + }); + + exception.Code.ShouldBe(IdentityErrorCodes.UserContextRequiredForRoleAssignment); + } + } + private static string CreateRandomEmail() { return Guid.NewGuid().ToString("N").Left(16) + "@abp.io";