계정 정보 다이얼로그 추가 및 전체 목록 페치 개선
This commit is contained in:
@@ -16,17 +16,36 @@ class AuthPermission {
|
||||
final normalized = PermissionResources.normalize(resource);
|
||||
final actionSet = <PermissionAction>{};
|
||||
for (final raw in actions) {
|
||||
final matched = PermissionAction.values.where(
|
||||
(action) => action.name == raw.trim().toLowerCase(),
|
||||
);
|
||||
if (matched.isEmpty) {
|
||||
final parsed = _parseAction(raw);
|
||||
if (parsed == null) {
|
||||
continue;
|
||||
}
|
||||
actionSet.addAll(matched);
|
||||
actionSet.add(parsed);
|
||||
}
|
||||
if (actionSet.isEmpty) {
|
||||
return <String, Set<PermissionAction>>{};
|
||||
}
|
||||
return {normalized: actionSet};
|
||||
}
|
||||
|
||||
/// 백엔드 권한 문자열을 [PermissionAction]으로 변환한다.
|
||||
///
|
||||
/// - 백엔드 스펙(`create`, `read`, `update`, `delete`, `restore`, `approve`)과
|
||||
/// 프런트 내부 별칭(`view`, `edit`)을 모두 인식한다.
|
||||
/// - 인식할 수 없는 문자열은 무시해 잘못된 권한이 섞여도 앱이 중단되지 않도록 한다.
|
||||
PermissionAction? _parseAction(String raw) {
|
||||
final key = raw.trim().toLowerCase();
|
||||
return _actionMap[key];
|
||||
}
|
||||
|
||||
static const Map<String, PermissionAction> _actionMap = {
|
||||
'view': PermissionAction.view,
|
||||
'read': PermissionAction.view,
|
||||
'create': PermissionAction.create,
|
||||
'edit': PermissionAction.edit,
|
||||
'update': PermissionAction.edit,
|
||||
'delete': PermissionAction.delete,
|
||||
'restore': PermissionAction.restore,
|
||||
'approve': PermissionAction.approve,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user