diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/UserApi.ts | 4 | ||||
-rw-r--r-- | src/api/server/ServerApi.ts | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/api/UserApi.ts b/src/api/UserApi.ts index 2b319207a..9364b3383 100644 --- a/src/api/UserApi.ts +++ b/src/api/UserApi.ts | |||
@@ -38,6 +38,10 @@ export default class UserApi { | |||
38 | return this.server.userInfo(); | 38 | return this.server.userInfo(); |
39 | } | 39 | } |
40 | 40 | ||
41 | requestNewToken() { | ||
42 | return this.server.requestNewToken(); | ||
43 | } | ||
44 | |||
41 | updateInfo(data: { oldPassword: string; newPassword: string }) { | 45 | updateInfo(data: { oldPassword: string; newPassword: string }) { |
42 | const userData = data; | 46 | const userData = data; |
43 | if (userData.oldPassword && userData.newPassword) { | 47 | if (userData.oldPassword && userData.newPassword) { |
diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 8e1d45588..c6cbbd2e2 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts | |||
@@ -151,6 +151,22 @@ export default class ServerApi { | |||
151 | return user; | 151 | return user; |
152 | } | 152 | } |
153 | 153 | ||
154 | async requestNewToken() { | ||
155 | if (apiBase() === SERVER_NOT_LOADED) { | ||
156 | throw new Error('Server not loaded'); | ||
157 | } | ||
158 | |||
159 | const request = await sendAuthRequest(`${apiBase()}/me/newtoken`); | ||
160 | if (!request.ok) { | ||
161 | throw new Error(request.statusText); | ||
162 | } | ||
163 | const data = await request.json(); | ||
164 | |||
165 | debug('ServerApi::requestNewToken new authToken received'); | ||
166 | |||
167 | return data; | ||
168 | } | ||
169 | |||
154 | async updateUserInfo(data: any) { | 170 | async updateUserInfo(data: any) { |
155 | const request = await sendAuthRequest(`${apiBase()}/me`, { | 171 | const request = await sendAuthRequest(`${apiBase()}/me`, { |
156 | method: 'PUT', | 172 | method: 'PUT', |