fix: frontend: change-password not displaying errors

Massimo Melina committed Apr 15, 2022 at 13:05 UTC 82ba54ac5ca082c4440593825210e51af83e9bf2
1 file changed +11 -6
frontend/src/UserPanel.ts
+11 -6
@@ -28,12 +28,17 @@ function Content() {
28 return alertDialog("The second password you entered did not match the first. Procedure aborted.", 'warning')
29 const srp6aNimbusRoutines = new SRPRoutines(new SRPParameters())
30 const res = await createVerifierAndSalt(srp6aNimbusRoutines, snap.username, pwd)
31 - await apiCall('change_srp', { salt: String(res.s), verifier: String(res.v) }).catch(e => {
32 - if (e.code !== 406) // 406 = server was configured to support clear text authentication
33 - throw e
34 - return apiCall('change_password', { newPassword: pwd }) // unencrypted version
35 - })
36 - return alertDialog("Password changed")
31 + try {
32 + await apiCall('change_srp', { salt: String(res.s), verifier: String(res.v) }).catch(e => {
33 + if (e.code !== 406) // 406 = server was configured to support clear text authentication
34 + throw e
35 + return apiCall('change_password', { newPassword: pwd }) // unencrypted version
36 + })
37 + return alertDialog("Password changed")
38 + }
39 + catch(e) {
40 + return alertDialog(e as Error)
41 + }
42 }
43 }),
44 h(MenuButton, {