aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/auth/oauth-model.ts3
-rw-r--r--server/models/user/user.ts6
-rw-r--r--server/models/utils.ts5
-rw-r--r--server/models/video/video-file.ts5
4 files changed, 9 insertions, 10 deletions
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index 81b6529d8..5d68f44e9 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -9,9 +9,9 @@ import { UserAdminFlag } from '@shared/models/users/user-flag.model'
9import { UserRole } from '@shared/models/users/user-role' 9import { UserRole } from '@shared/models/users/user-role'
10import { logger } from '../../helpers/logger' 10import { logger } from '../../helpers/logger'
11import { CONFIG } from '../../initializers/config' 11import { CONFIG } from '../../initializers/config'
12import { UserModel } from '../../models/user/user'
13import { OAuthClientModel } from '../../models/oauth/oauth-client' 12import { OAuthClientModel } from '../../models/oauth/oauth-client'
14import { OAuthTokenModel } from '../../models/oauth/oauth-token' 13import { OAuthTokenModel } from '../../models/oauth/oauth-token'
14import { UserModel } from '../../models/user/user'
15import { createUserAccountAndChannelAndPlaylist } from '../user' 15import { createUserAccountAndChannelAndPlaylist } from '../user'
16import { TokensCache } from './tokens-cache' 16import { TokensCache } from './tokens-cache'
17 17
@@ -116,6 +116,7 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin
116 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).') 116 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).')
117 117
118 const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail) 118 const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail)
119
119 // If we don't find the user, or if the user belongs to a plugin 120 // If we don't find the user, or if the user belongs to a plugin
120 if (!user || user.pluginAuth !== null || !password) return null 121 if (!user || user.pluginAuth !== null || !password) return null
121 122
diff --git a/server/models/user/user.ts b/server/models/user/user.ts
index e7bf22806..ad8ce08cb 100644
--- a/server/models/user/user.ts
+++ b/server/models/user/user.ts
@@ -48,14 +48,14 @@ import {
48 isUserEmailVerifiedValid, 48 isUserEmailVerifiedValid,
49 isUserNoModal, 49 isUserNoModal,
50 isUserNSFWPolicyValid, 50 isUserNSFWPolicyValid,
51 isUserP2PEnabledValid,
51 isUserPasswordValid, 52 isUserPasswordValid,
52 isUserRoleValid, 53 isUserRoleValid,
53 isUserUsernameValid, 54 isUserUsernameValid,
54 isUserVideoLanguages, 55 isUserVideoLanguages,
55 isUserVideoQuotaDailyValid, 56 isUserVideoQuotaDailyValid,
56 isUserVideoQuotaValid, 57 isUserVideoQuotaValid,
57 isUserVideosHistoryEnabledValid, 58 isUserVideosHistoryEnabledValid
58 isUserP2PEnabledValid
59} from '../../helpers/custom-validators/users' 59} from '../../helpers/custom-validators/users'
60import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' 60import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
61import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' 61import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants'
@@ -623,7 +623,7 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> {
623 const query = { 623 const query = {
624 where: { 624 where: {
625 [Op.or]: [ 625 [Op.or]: [
626 where(fn('lower', col('username')), '=', fn('lower', username)), 626 where(fn('lower', col('username')), fn('lower', username) as any),
627 627
628 { email } 628 { email }
629 ] 629 ]
diff --git a/server/models/utils.ts b/server/models/utils.ts
index 0950f5f32..66b653e3d 100644
--- a/server/models/utils.ts
+++ b/server/models/utils.ts
@@ -1,5 +1,4 @@
1import { literal, Op, OrderItem, Sequelize } from 'sequelize' 1import { literal, Op, OrderItem, Sequelize } from 'sequelize'
2import { Col } from 'sequelize/types/utils'
3import validator from 'validator' 2import validator from 'validator'
4 3
5type SortType = { sortModel: string, sortValue: string } 4type SortType = { sortModel: string, sortValue: string }
@@ -8,7 +7,7 @@ type SortType = { sortModel: string, sortValue: string }
8function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { 7function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
9 const { direction, field } = buildDirectionAndField(value) 8 const { direction, field } = buildDirectionAndField(value)
10 9
11 let finalField: string | Col 10 let finalField: string | ReturnType<typeof Sequelize.col>
12 11
13 if (field.toLowerCase() === 'match') { // Search 12 if (field.toLowerCase() === 'match') { // Search
14 finalField = Sequelize.col('similarity') 13 finalField = Sequelize.col('similarity')
@@ -65,7 +64,7 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or
65 ] 64 ]
66 } 65 }
67 66
68 let finalField: string | Col 67 let finalField: string | ReturnType<typeof Sequelize.col>
69 68
70 // Alias 69 // Alias
71 if (field.toLowerCase() === 'match') { // Search 70 if (field.toLowerCase() === 'match') { // Search
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 1a9f4561a..fae76c6f2 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -1,7 +1,7 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import memoizee from 'memoizee' 2import memoizee from 'memoizee'
3import { join } from 'path' 3import { join } from 'path'
4import { FindOptions, Op, Transaction } from 'sequelize' 4import { FindOptions, Op, Transaction, WhereOptions } from 'sequelize'
5import { 5import {
6 AllowNull, 6 AllowNull,
7 BelongsTo, 7 BelongsTo,
@@ -18,7 +18,6 @@ import {
18 Table, 18 Table,
19 UpdatedAt 19 UpdatedAt
20} from 'sequelize-typescript' 20} from 'sequelize-typescript'
21import { Where } from 'sequelize/types/utils'
22import validator from 'validator' 21import validator from 'validator'
23import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' 22import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
24import { logger } from '@server/helpers/logger' 23import { logger } from '@server/helpers/logger'
@@ -70,7 +69,7 @@ export enum ScopeNames {
70 } 69 }
71 ] 70 ]
72 }, 71 },
73 [ScopeNames.WITH_VIDEO_OR_PLAYLIST]: (options: { whereVideo?: Where } = {}) => { 72 [ScopeNames.WITH_VIDEO_OR_PLAYLIST]: (options: { whereVideo?: WhereOptions } = {}) => {
74 return { 73 return {
75 include: [ 74 include: [
76 { 75 {