mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
This commit is contained in:
parent
5fe7e89831
commit
6fcd19ba73
88 changed files with 1980 additions and 2505 deletions
|
@ -30,17 +30,10 @@ function getUser (username: string, password: string) {
|
|||
return db.User.getByUsername(username).then(function (user) {
|
||||
if (!user) return null
|
||||
|
||||
// We need to return a promise
|
||||
return new Promise(function (resolve, reject) {
|
||||
return user.isPasswordMatch(password, function (err, isPasswordMatch) {
|
||||
if (err) return reject(err)
|
||||
return user.isPasswordMatch(password).then(passwordMatch => {
|
||||
if (passwordMatch === false) return null
|
||||
|
||||
if (isPasswordMatch === true) {
|
||||
return resolve(user)
|
||||
}
|
||||
|
||||
return resolve(null)
|
||||
})
|
||||
return user
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -80,8 +73,6 @@ function saveToken (token: TokenInfo, client: OAuthClientInstance, user: UserIns
|
|||
tokenCreated.user = user
|
||||
|
||||
return tokenCreated
|
||||
}).catch(function (err) {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue