aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-04 10:57:36 +0100
committerChocobozzz <me@florianbigard.com>2022-03-04 10:57:36 +0100
commitd3d3deaa7aae49d6d949aebcba015af75d292ccc (patch)
tree42e487810f5b7362c28f744371d160a4effc7566 /server/initializers
parent90370f7cc85ee4b45eb0d1bafed2d9d68610df9f (diff)
downloadPeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.tar.gz
PeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.tar.zst
PeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.zip
Refactor user build and express file middlewares
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/installer.ts12
1 files changed, 4 insertions, 8 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 7e321fb76..0517e0084 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -2,10 +2,9 @@ import { ensureDir, remove } from 'fs-extra'
2import passwordGenerator from 'password-generator' 2import passwordGenerator from 'password-generator'
3import { UserRole } from '@shared/models' 3import { UserRole } from '@shared/models'
4import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
5import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' 5import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { UserModel } from '../models/user/user'
9import { applicationExist, clientsExist, usersExist } from './checker-after-init' 8import { applicationExist, clientsExist, usersExist } from './checker-after-init'
10import { CONFIG } from './config' 9import { CONFIG } from './config'
11import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' 10import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
@@ -137,18 +136,15 @@ async function createOAuthAdminIfNotExist () {
137 password = passwordGenerator(16, true) 136 password = passwordGenerator(16, true)
138 } 137 }
139 138
140 const userData = { 139 const user = buildUser({
141 username, 140 username,
142 email, 141 email,
143 password, 142 password,
144 role, 143 role,
145 verified: true, 144 emailVerified: true,
146 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
147 p2pEnabled: CONFIG.DEFAULTS.P2P.WEBAPP.ENABLED,
148 videoQuota: -1, 145 videoQuota: -1,
149 videoQuotaDaily: -1 146 videoQuotaDaily: -1
150 } 147 })
151 const user = new UserModel(userData)
152 148
153 await createUserAccountAndChannelAndPlaylist({ userToCreate: user, channelNames: undefined, validateUser: validatePassword }) 149 await createUserAccountAndChannelAndPlaylist({ userToCreate: user, channelNames: undefined, validateUser: validatePassword })
154 logger.info('Username: ' + username) 150 logger.info('Username: ' + username)