aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/oauth')
-rw-r--r--server/models/oauth/oauth-token.ts39
1 files changed, 21 insertions, 18 deletions
diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts
index a0a13aab7..5c3781394 100644
--- a/server/models/oauth/oauth-token.ts
+++ b/server/models/oauth/oauth-token.ts
@@ -98,24 +98,27 @@ getByRefreshTokenAndPopulateClient = function (refreshToken: string) {
98 include: [ OAuthToken['sequelize'].models.OAuthClient ] 98 include: [ OAuthToken['sequelize'].models.OAuthClient ]
99 } 99 }
100 100
101 return OAuthToken.findOne(query).then(function (token) { 101 return OAuthToken.findOne(query)
102 if (!token) return null 102 .then(token => {
103 103 if (!token) return null
104 const tokenInfos: OAuthTokenInfo = { 104
105 refreshToken: token.refreshToken, 105 const tokenInfos: OAuthTokenInfo = {
106 refreshTokenExpiresAt: token.refreshTokenExpiresAt, 106 refreshToken: token.refreshToken,
107 client: { 107 refreshTokenExpiresAt: token.refreshTokenExpiresAt,
108 id: token['client'].id 108 client: {
109 }, 109 id: token['client'].id
110 user: { 110 },
111 id: token['user'] 111 user: {
112 id: token['user']
113 }
112 } 114 }
113 }
114 115
115 return tokenInfos 116 return tokenInfos
116 }).catch(function (err) { 117 })
117 logger.info('getRefreshToken error.', err) 118 .catch(err => {
118 }) 119 logger.info('getRefreshToken error.', err)
120 throw err
121 })
119} 122}
120 123
121getByTokenAndPopulateUser = function (bearerToken: string) { 124getByTokenAndPopulateUser = function (bearerToken: string) {
@@ -126,7 +129,7 @@ getByTokenAndPopulateUser = function (bearerToken: string) {
126 include: [ OAuthToken['sequelize'].models.User ] 129 include: [ OAuthToken['sequelize'].models.User ]
127 } 130 }
128 131
129 return OAuthToken.findOne(query).then(function (token) { 132 return OAuthToken.findOne(query).then(token => {
130 if (token) token['user'] = token.User 133 if (token) token['user'] = token.User
131 134
132 return token 135 return token
@@ -141,7 +144,7 @@ getByRefreshTokenAndPopulateUser = function (refreshToken: string) {
141 include: [ OAuthToken['sequelize'].models.User ] 144 include: [ OAuthToken['sequelize'].models.User ]
142 } 145 }
143 146
144 return OAuthToken.findOne(query).then(function (token) { 147 return OAuthToken.findOne(query).then(token => {
145 token['user'] = token.User 148 token['user'] = token.User
146 149
147 return token 150 return token