1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Ensure user is owned by plugin before updating it

This commit is contained in:
Chocobozzz 2023-12-06 08:43:19 +01:00
parent c6047e1573
commit 4fd8d34175
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 30 additions and 2 deletions

View file

@ -89,8 +89,11 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin
let user = await UserModel.loadByEmail(bypassLogin.user.email)
if (!user) user = await createUserFromExternal(bypassLogin.pluginName, bypassLogin.user)
else user = await updateUserFromExternal(user, bypassLogin.user, bypassLogin.userUpdater)
if (!user) {
user = await createUserFromExternal(bypassLogin.pluginName, bypassLogin.user)
} else if (user.pluginAuth === bypassLogin.pluginName) {
user = await updateUserFromExternal(user, bypassLogin.user, bypassLogin.userUpdater)
}
// Cannot create a user
if (!user) throw new AccessDeniedError('Cannot create such user: an actor with that name already exists.')