fix: frontend: regression on change-password

Massimo Melina committed Apr 15, 2022 at 13:04 UTC c88265110337cf8d1be71fdd836ce86df24d7015
3 files changed +8 -4
admin/src/AccountsPage.ts
+2 -2
@@ -219,9 +219,9 @@ function account2icon(ac: Account, props={}) {
219 async function apiNewPassword(username: string, password: string) {
220 const srp6aNimbusRoutines = new SRPRoutines(new SRPParameters())
221 const res = await createVerifierAndSalt(srp6aNimbusRoutines, username, password)
222 - return apiCall('change_srp', { username, salt: String(res.s), verifier: String(res.v) }).catch(e => {
222 + return apiCall('change_srp_others', { username, salt: String(res.s), verifier: String(res.v) }).catch(e => {
223 if (e.code !== 406) // 406 = server was configured to support clear text authentication
224 throw e
225 - return apiCall('change_password', { username, newPassword: password }) // unencrypted version
225 + return apiCall('change_password_others', { username, newPassword: password }) // unencrypted version
226 })
227 }
server/src/api.accounts.ts
+2 -2
@@ -65,11 +65,11 @@ const apis: ApiHandlers = {
65 return delAccount(username) ? {} : new ApiError(400)
66 },
67
68 - async change_password({ username, newPassword }) {
68 + async change_password_others({ username, newPassword }) {
69 return changePasswordHelper(getAccount(username), newPassword)
70 },
71
72 - async change_srp({ username, salt, verifier }) {
72 + async change_srp_others({ username, salt, verifier }) {
73 return changeSrpHelper(getAccount(username), salt, verifier)
74 }
75
server/src/index.ts
+4
@@ -12,6 +12,10 @@ import { headRequests, gzipper, sessions, serveGuiAndSharedFiles, someSecurity,
12 import './listen'
13 import { adminApis } from './adminApis'
14 import { subscribeConfig } from './config'
15 +import { ok } from 'assert'
16 +import _ from 'lodash'
17 +
18 +ok(_.intersection(Object.keys(frontEndApis), Object.keys(adminApis)).length === 0) // they share same endpoints
19
20 const keys = ['hfs-keys-test']
21 export const app = new Koa({ keys })