mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
Fix server folder permissions by role
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { User } from '@prisma/client';
|
||||
import { Request } from 'express';
|
||||
import { OffsetPagination } from '@/types/types';
|
||||
import { ApiError } from '@/utils';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { AuthUser } from '@middleware/authenticate';
|
||||
import { folderPermissions } from '@utils/folder-permissions';
|
||||
|
||||
const findById = async (options: { id: string; user: User }) => {
|
||||
const findById = async (options: { id: string; user: AuthUser }) => {
|
||||
const { id, user } = options;
|
||||
const albumArtist = await prisma.albumArtist.findUnique({
|
||||
include: {
|
||||
@@ -34,7 +34,7 @@ const findById = async (options: { id: string; user: User }) => {
|
||||
|
||||
const findMany = async (
|
||||
req: Request,
|
||||
options: { serverFolderIds: string; user: User } & OffsetPagination
|
||||
options: { serverFolderIds: string; user: AuthUser } & OffsetPagination
|
||||
) => {
|
||||
const { user, take, serverFolderIds: rServerFolderIds, skip } = options;
|
||||
const serverFolderIds = rServerFolderIds.split(',');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { User } from '@prisma/client';
|
||||
import { Request } from 'express';
|
||||
import { AuthUser } from '@middleware/authenticate';
|
||||
import { prisma } from '../lib';
|
||||
import { OffsetPagination } from '../types/types';
|
||||
import { ApiError, folderPermissions } from '../utils';
|
||||
|
||||
const findById = async (options: { id: string; user: User }) => {
|
||||
const findById = async (options: { id: string; user: AuthUser }) => {
|
||||
const { id, user } = options;
|
||||
|
||||
const artist = await prisma.artist.findUnique({
|
||||
@@ -26,7 +26,7 @@ const findById = async (options: { id: string; user: User }) => {
|
||||
|
||||
const findMany = async (
|
||||
req: Request,
|
||||
options: { serverFolderIds: string; user: User } & OffsetPagination
|
||||
options: { serverFolderIds: string; user: AuthUser } & OffsetPagination
|
||||
) => {
|
||||
const { user, skip, take, serverFolderIds: rServerFolderIds } = options;
|
||||
const serverFolderIds = rServerFolderIds.split(',');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { User } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { AuthUser } from '@middleware/authenticate';
|
||||
import { prisma } from '../lib';
|
||||
import { generateRefreshToken, generateToken } from '../lib/passport';
|
||||
import { ApiSuccess, randomString } from '../utils';
|
||||
@@ -57,7 +57,7 @@ const register = async (options: { password: string; username: string }) => {
|
||||
return user;
|
||||
};
|
||||
|
||||
const logout = async (options: { user: User }) => {
|
||||
const logout = async (options: { user: AuthUser }) => {
|
||||
const { user } = options;
|
||||
await prisma.refreshToken.deleteMany({
|
||||
where: { userId: user.id },
|
||||
|
||||
Reference in New Issue
Block a user