diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-01-06 12:09:57 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-01-06 12:09:57 +0900 |
| commit | fef3d3f300c80bf26b0c6a203db5782f76463151 (patch) | |
| tree | 4b590d2c11e2d1f031cc3fff9ef1c9c76741cdc6 /src/api/authenticate.ts | |
| parent | [BREAKING CHANGE] Improve security (diff) | |
| download | sharkey-fef3d3f300c80bf26b0c6a203db5782f76463151.tar.gz sharkey-fef3d3f300c80bf26b0c6a203db5782f76463151.tar.bz2 sharkey-fef3d3f300c80bf26b0c6a203db5782f76463151.zip | |
Refactor: Rename userkey --> access-token
Diffstat (limited to 'src/api/authenticate.ts')
| -rw-r--r-- | src/api/authenticate.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index 0a888e72d3..2304acff21 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -1,7 +1,7 @@ import * as express from 'express'; import App from './models/app'; import User from './models/user'; -import Userkey from './models/userkey'; +import AccessToken from './models/access-token'; import isNativeToken from './common/is-native-token'; export interface IAuthContext { @@ -42,19 +42,19 @@ export default (req: express.Request) => new Promise<IAuthContext>(async (resolv isSecure: true }); } else { - const userkeyDoc = await Userkey.findOne({ + const accessToken = await AccessToken.findOne({ hash: token }); - if (userkeyDoc === null) { - return reject('invalid userkey'); + if (accessToken === null) { + return reject('invalid token'); } const app = await App - .findOne({ _id: userkeyDoc.app_id }); + .findOne({ _id: accessToken.app_id }); const user = await User - .findOne({ _id: userkeyDoc.user_id }); + .findOne({ _id: accessToken.user_id }); return resolve({ app: app, user: user, isSecure: false }); } |