diff --git a/overseerr-api.yml b/overseerr-api.yml index 9b9f888ed..6290c9ccf 100644 --- a/overseerr-api.yml +++ b/overseerr-api.yml @@ -23,11 +23,13 @@ components: userType: type: integer example: 1 + readOnly: true permissions: type: number example: 0 avatar: type: string + readOnly: true createdAt: type: string example: '2020-09-02T05:02:23.000Z' @@ -47,9 +49,7 @@ components: $ref: '#/components/schemas/MediaRequest' required: - id - - userType - email - - permissions - createdAt - updatedAt MainSettings: diff --git a/server/entity/User.ts b/server/entity/User.ts index 5ba205357..0b05efb22 100644 --- a/server/entity/User.ts +++ b/server/entity/User.ts @@ -15,6 +15,7 @@ import PreparedEmail from '../lib/email'; import logger from '../logger'; import { getSettings } from '../lib/settings'; import { default as generatePassword } from 'secure-random-password'; +import { UserType } from '../constants/user'; @Entity() export class User { @@ -36,8 +37,8 @@ export class User { @Column({ nullable: true, select: false }) public password?: string; - @Column({ type: 'integer', default: 1 }) - public userType = 1; + @Column({ type: 'integer', default: UserType.PLEX }) + public userType: UserType; @Column({ nullable: true, select: false }) public plexId?: number; diff --git a/server/routes/auth.ts b/server/routes/auth.ts index 21c9397a9..5f60d5120 100644 --- a/server/routes/auth.ts +++ b/server/routes/auth.ts @@ -68,6 +68,7 @@ authRoutes.post('/login', async (req, res, next) => { plexToken: account.authToken, permissions: Permission.ADMIN, avatar: account.thumb, + userType: UserType.PLEX, }); await userRepository.save(user); } @@ -90,6 +91,7 @@ authRoutes.post('/login', async (req, res, next) => { plexToken: account.authToken, permissions: settings.main.defaultPermissions, avatar: account.thumb, + userType: UserType.PLEX, }); await userRepository.save(user); } else { diff --git a/server/routes/user.ts b/server/routes/user.ts index 3807c8497..b51b56cd1 100644 --- a/server/routes/user.ts +++ b/server/routes/user.ts @@ -7,6 +7,7 @@ import { hasPermission, Permission } from '../lib/permissions'; import { getSettings } from '../lib/settings'; import logger from '../logger'; import gravatarUrl from 'gravatar-url'; +import { UserType } from '../constants/user'; const router = Router(); @@ -26,7 +27,7 @@ router.post('/', async (req, res, next) => { const userRepository = getRepository(User); const passedExplicitPassword = body.password && body.password.length > 0; - const avatar = gravatarUrl(body.email); + const avatar = gravatarUrl(body.email, { default: 'mm', size: 200 }); if (!passedExplicitPassword && !settings.enabled) { throw new Error('Email notifications must be enabled'); @@ -37,9 +38,9 @@ router.post('/', async (req, res, next) => { username: body.username ?? body.email, email: body.email, password: body.password, - permissions: body.permissions, + permissions: Permission.REQUEST, plexToken: '', - userType: body.userType, + userType: UserType.LOCAL, }); if (passedExplicitPassword) { @@ -201,6 +202,7 @@ router.post('/import-from-plex', async (req, res, next) => { plexId: parseInt(account.id), plexToken: '', avatar: account.thumb, + userType: UserType.PLEX, }); await userRepository.save(newUser); createdUsers.push(newUser); diff --git a/src/components/PermissionOption/index.tsx b/src/components/PermissionOption/index.tsx index d779669db..f8c0677bb 100644 --- a/src/components/PermissionOption/index.tsx +++ b/src/components/PermissionOption/index.tsx @@ -59,7 +59,7 @@ const PermissionOption: React.FC = ({ !hasPermission(Permission.MANAGE_SETTINGS, user.permissions) && option.permission === Permission.MANAGE_SETTINGS) } - onClick={() => { + onChange={() => { onUpdate( hasPermission(option.permission, currentPermission) ? currentPermission - option.permission diff --git a/src/components/UserEdit/index.tsx b/src/components/UserEdit/index.tsx index 3a09e11a3..772d77ce7 100644 --- a/src/components/UserEdit/index.tsx +++ b/src/components/UserEdit/index.tsx @@ -79,7 +79,6 @@ const UserEdit: React.FC = () => { await axios.put(`/api/v1/user/${user?.id}`, { permissions: currentPermission, email: user?.email, - avatar: user?.avatar, }); addToast(intl.formatMessage(messages.usersaved), { diff --git a/src/components/UserList/index.tsx b/src/components/UserList/index.tsx index 1669f9c0b..7b7d6af1b 100644 --- a/src/components/UserList/index.tsx +++ b/src/components/UserList/index.tsx @@ -204,8 +204,6 @@ const UserList: React.FC = () => { await axios.post('/api/v1/user', { email: values.email, password: values.genpassword ? null : values.password, - permissions: Permission.REQUEST, - userType: UserType.LOCAL, }); addToast(intl.formatMessage(messages.usercreatedsuccess), { appearance: 'success', @@ -315,7 +313,7 @@ const UserList: React.FC = () => { }} -
+
{intl.formatMessage(messages.userlist)}