mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-01-24 16:09:05 +01:00
Fix permission bugs
This commit is contained in:
@@ -25,7 +25,7 @@ const SystemRoleDefaultsTyped: {
|
||||
guest: [Permission.ImageView, Permission.UserLogin],
|
||||
user: [
|
||||
Permission.ImageView,
|
||||
Permission.UserMe,
|
||||
Permission.UserKeepLogin,
|
||||
Permission.UserLogin,
|
||||
Permission.Settings,
|
||||
Permission.ImageUpload,
|
||||
|
||||
@@ -36,12 +36,14 @@ export class PrefController {
|
||||
throw new InternalServerErrorException('Could not get preferences');
|
||||
}
|
||||
|
||||
const returned = new MultipleSysPreferencesResponse();
|
||||
returned.preferences = prefs.map((pref) =>
|
||||
plainToClass(SysPreferenceBaseResponse, pref),
|
||||
);
|
||||
const returned: MultipleSysPreferencesResponse = {
|
||||
preferences: prefs.map((pref) =>
|
||||
plainToClass(SysPreferenceBaseResponse, pref),
|
||||
),
|
||||
total: prefs.length,
|
||||
};
|
||||
|
||||
return returned;
|
||||
return plainToClass(MultipleSysPreferencesResponse, returned);
|
||||
}
|
||||
|
||||
@Get('sys/:key')
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
Request
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
Post,
|
||||
Request
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
UserLoginResponse,
|
||||
UserMePermissionsResponse,
|
||||
UserMeResponse,
|
||||
UserRegisterRequest,
|
||||
UserRegisterResponse
|
||||
UserLoginResponse,
|
||||
UserMePermissionsResponse,
|
||||
UserMeResponse,
|
||||
UserRegisterRequest,
|
||||
UserRegisterResponse
|
||||
} from 'picsur-shared/dist/dto/api/user.dto';
|
||||
import { Permission } from 'picsur-shared/dist/dto/permissions';
|
||||
import { HasFailed } from 'picsur-shared/dist/types';
|
||||
import { UsersService } from '../../../collections/userdb/userdb.service';
|
||||
import { UserRolesService } from '../../../collections/userdb/userrolesdb.service';
|
||||
import {
|
||||
NoPermissions,
|
||||
RequiredPermissions,
|
||||
UseLocalAuth
|
||||
NoPermissions,
|
||||
RequiredPermissions,
|
||||
UseLocalAuth
|
||||
} from '../../../decorators/permissions.decorator';
|
||||
import { AuthManagerService } from '../../../managers/auth/auth.service';
|
||||
import AuthFasityRequest from '../../../models/requests/authrequest.dto';
|
||||
@@ -62,7 +62,7 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@RequiredPermissions(Permission.UserMe)
|
||||
@RequiredPermissions(Permission.UserKeepLogin)
|
||||
async me(@Request() req: AuthFasityRequest): Promise<UserMeResponse> {
|
||||
const user = await this.usersService.findOne(req.user.username);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ export enum Permission {
|
||||
ImageUpload = 'image-upload',
|
||||
|
||||
UserLogin = 'user-login', // Ability to log in
|
||||
UserMe = 'user-me', // Ability to view own user details and refresh token
|
||||
UserKeepLogin = 'user-keep-login', // Ability to view own user details and refresh token
|
||||
UserRegister = 'user-register', // Ability to register
|
||||
|
||||
Settings = 'settings', // Ability to view (personal) settings
|
||||
@@ -35,7 +35,7 @@ export const UIFriendlyPermissions: {
|
||||
[Permission.ImageUpload]: 'Upload images',
|
||||
|
||||
[Permission.UserLogin]: 'Login',
|
||||
[Permission.UserMe]: 'View self',
|
||||
[Permission.UserKeepLogin]: 'Stay Logged In',
|
||||
[Permission.UserRegister]: 'Register',
|
||||
|
||||
[Permission.Settings]: 'View settings',
|
||||
|
||||
Reference in New Issue
Block a user