aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth-token.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/models/oauth-token.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip
Type functions
Diffstat (limited to 'server/models/oauth-token.ts')
-rw-r--r--server/models/oauth-token.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/models/oauth-token.ts b/server/models/oauth-token.ts
index 567df1c12..d70bd2bce 100644
--- a/server/models/oauth-token.ts
+++ b/server/models/oauth-token.ts
@@ -8,7 +8,8 @@ import {
8 OAuthTokenInstance, 8 OAuthTokenInstance,
9 OAuthTokenAttributes, 9 OAuthTokenAttributes,
10 10
11 OAuthTokenMethods 11 OAuthTokenMethods,
12 OAuthTokenInfo
12} from './oauth-token-interface' 13} from './oauth-token-interface'
13 14
14let OAuthToken: Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> 15let OAuthToken: Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes>
@@ -90,7 +91,7 @@ function associate (models) {
90 }) 91 })
91} 92}
92 93
93getByRefreshTokenAndPopulateClient = function (refreshToken) { 94getByRefreshTokenAndPopulateClient = function (refreshToken: string) {
94 const query = { 95 const query = {
95 where: { 96 where: {
96 refreshToken: refreshToken 97 refreshToken: refreshToken
@@ -99,9 +100,9 @@ getByRefreshTokenAndPopulateClient = function (refreshToken) {
99 } 100 }
100 101
101 return OAuthToken.findOne(query).then(function (token) { 102 return OAuthToken.findOne(query).then(function (token) {
102 if (!token) return token 103 if (!token) return null
103 104
104 const tokenInfos = { 105 const tokenInfos: OAuthTokenInfo = {
105 refreshToken: token.refreshToken, 106 refreshToken: token.refreshToken,
106 refreshTokenExpiresAt: token.refreshTokenExpiresAt, 107 refreshTokenExpiresAt: token.refreshTokenExpiresAt,
107 client: { 108 client: {
@@ -118,7 +119,7 @@ getByRefreshTokenAndPopulateClient = function (refreshToken) {
118 }) 119 })
119} 120}
120 121
121getByTokenAndPopulateUser = function (bearerToken) { 122getByTokenAndPopulateUser = function (bearerToken: string) {
122 const query = { 123 const query = {
123 where: { 124 where: {
124 accessToken: bearerToken 125 accessToken: bearerToken
@@ -133,7 +134,7 @@ getByTokenAndPopulateUser = function (bearerToken) {
133 }) 134 })
134} 135}
135 136
136getByRefreshTokenAndPopulateUser = function (refreshToken) { 137getByRefreshTokenAndPopulateUser = function (refreshToken: string) {
137 const query = { 138 const query = {
138 where: { 139 where: {
139 refreshToken: refreshToken 140 refreshToken: refreshToken