diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 13:26:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 14:14:16 +0200 |
commit | 6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch) | |
tree | 3365a96d82bc7f00ae504a568725c8e914150cf8 /server/lib/oauth-model.ts | |
parent | 5fe7e898316e18369c3e1aba307b55077adc7bfb (diff) | |
download | PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip |
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r-- | server/lib/oauth-model.ts | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 7cf42e94c..f34c9c667 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -30,17 +30,10 @@ function getUser (username: string, password: string) { | |||
30 | return db.User.getByUsername(username).then(function (user) { | 30 | return db.User.getByUsername(username).then(function (user) { |
31 | if (!user) return null | 31 | if (!user) return null |
32 | 32 | ||
33 | // We need to return a promise | 33 | return user.isPasswordMatch(password).then(passwordMatch => { |
34 | return new Promise(function (resolve, reject) { | 34 | if (passwordMatch === false) return null |
35 | return user.isPasswordMatch(password, function (err, isPasswordMatch) { | ||
36 | if (err) return reject(err) | ||
37 | 35 | ||
38 | if (isPasswordMatch === true) { | 36 | return user |
39 | return resolve(user) | ||
40 | } | ||
41 | |||
42 | return resolve(null) | ||
43 | }) | ||
44 | }) | 37 | }) |
45 | }) | 38 | }) |
46 | } | 39 | } |
@@ -80,8 +73,6 @@ function saveToken (token: TokenInfo, client: OAuthClientInstance, user: UserIns | |||
80 | tokenCreated.user = user | 73 | tokenCreated.user = user |
81 | 74 | ||
82 | return tokenCreated | 75 | return tokenCreated |
83 | }).catch(function (err) { | ||
84 | throw err | ||
85 | }) | 76 | }) |
86 | } | 77 | } |
87 | 78 | ||