@mohasinac/appkit 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,7 +21,6 @@ export async function getServerPermissions(uid) {
|
|
|
21
21
|
return { isAdmin: false, permissions: [] };
|
|
22
22
|
// userRepository.findById is cached per request in BaseRepository
|
|
23
23
|
const user = await userRepository.findById(uid);
|
|
24
|
-
console.error("[PERM-DIAG] uid:", uid, "user:", user ? JSON.stringify(user) : "null");
|
|
25
24
|
if (!user)
|
|
26
25
|
return { isAdmin: false, permissions: [] };
|
|
27
26
|
if (user.role === "admin")
|
|
@@ -38,7 +38,15 @@ export class UserRepository extends BaseRepository {
|
|
|
38
38
|
return this.decryptUser(raw);
|
|
39
39
|
}
|
|
40
40
|
async createWithId(id, data) {
|
|
41
|
-
|
|
41
|
+
// `uid` is a required UserDocument field read directly off the mapped
|
|
42
|
+
// object (SessionUser.uid, getServerPermissions(uid), etc.) — mapDoc()
|
|
43
|
+
// only auto-populates `.id` from the Firestore doc ID, not `.uid`. A
|
|
44
|
+
// caller passing `data` without `uid` silently produces a user record
|
|
45
|
+
// that authenticates fine but fails every downstream role/permission
|
|
46
|
+
// check with no error anywhere (found via a live RBAC bug where an
|
|
47
|
+
// admin account created this way couldn't access /admin).
|
|
48
|
+
const withUid = { uid: id, ...data };
|
|
49
|
+
const encrypted = this.encryptUserData(withUid);
|
|
42
50
|
return super.createWithId(id, encrypted);
|
|
43
51
|
}
|
|
44
52
|
async create(input) {
|