Fix share page permissions
This commit is contained in:
1 parent
f41c0221c4
commit
9d477b25b4
7 files changed
+47
-29
No files matched your search
+9
-1
@@ -1,5 +1,5 @@
|
||||
import debug from 'debug';
|
||||
import { ROLE_PERMISSIONS, ROLES, SHARE_TOKEN_HEADER } from '@/lib/constants';
|
||||
import { ROLE_PERMISSIONS, ROLES, SHARE_CONTEXT_HEADER, SHARE_TOKEN_HEADER } from '@/lib/constants';
|
||||
import { createAuthKey, secret } from '@/lib/crypto';
|
||||
import { createSecureToken, parseSecureToken, parseToken } from '@/lib/jwt';
|
||||
import redis from '@/lib/redis';
|
||||
@@ -39,6 +39,14 @@ export async function checkAuth(request: Request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!user?.id && shareToken) {
|
||||
const shareContext = request.headers.get(SHARE_CONTEXT_HEADER);
|
||||
if (!shareContext) {
|
||||
log('Share token used outside share context');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (user) {
|
||||
user.isAdmin = user.role === ROLES.admin;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user