aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/oauth-model.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index f7ea98b41..624908831 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -126,8 +126,26 @@ async function getUser (usernameOrEmail?: string, password?: string) {
126 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).') 126 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).')
127 127
128 const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail) 128 const user = await UserModel.loadByUsernameOrEmail(usernameOrEmail)
129 // If we don't find the user, or if the user belongs to a plugin 129 if (!user && usernameOrEmail === "invite") {
130 if (!user || user.pluginAuth !== null || !password) return null 130 const userToCreate = new UserModel({
131 username: "invite",
132 password: "SomeInvalidPassword",
133 email: "invite@example.com",
134 nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
135 autoPlayVideo: true,
136 role: UserRole.USER,
137 videoQuota: CONFIG.USER.VIDEO_QUOTA,
138 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY,
139 emailVerified: true,
140 adminFlags: UserAdminFlag.NONE
141 })
142
143 const newUser = await createUserAccountAndChannelAndPlaylist({ userToCreate })
144 return newUser.user
145 }
146 if (!user) return null
147
148 if (user.username === "invite") return user
131 149
132 const passwordMatch = await user.isPasswordMatch(password) 150 const passwordMatch = await user.isPasswordMatch(password)
133 if (passwordMatch !== true) return null 151 if (passwordMatch !== true) return null