aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth/oauth-token.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-11 17:04:57 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-11 17:05:55 +0200
commit075f16caac5236cb04c98ae7b3a989766d764bb3 (patch)
tree9a30024aa771735a28d83d9a166033b82dbcaf60 /server/models/oauth/oauth-token.ts
parent4e979c3e1b81f4762025d9db3052b1f70774b3bb (diff)
downloadPeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.gz
PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.zst
PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.zip
Remove "function" in favor of () => {}
Diffstat (limited to 'server/models/oauth/oauth-token.ts')
-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