Skip to content

Commit

Permalink
client/webserver: remove legacy seed js validation (#2966)
Browse files Browse the repository at this point in the history
* client/webserver: remove legacy seed js validation

We recently moved from hex seeds to mnemonics but had
a leftover js check that only works for legacy seeds and errors
for the new mnemonic seed format.

This PR removes that legacy js validation and fixes a bug with
PASSWORD_RESET_SUCCESS_MSG locale translation key.

* refresh password reset form before display
---------

Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon authored Sep 12, 2024
1 parent ae2fbd0 commit c3ed943
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 0 additions & 4 deletions client/webserver/jsintl.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ const (
ticketStatusExpiredID = "TICKET_STATUS_EXPIRED"
ticketStatusUnspentID = "TICKET_STATUS_UNSPENT"
ticketStatusRevokedID = "TICKET_STATUS_REVOKED"
invalidSeedID = "INVALID_SEED"
passwordResetSuccessMsgID = "PASSWORD_RESET_SUCCESS_MSG"
browserNtfnEnabledID = "BROWSER_NTFN_ENABLED"
browserNtfnOrdersID = "BROWSER_NTFN_ORDERS"
Expand Down Expand Up @@ -341,7 +340,6 @@ var enUS = map[string]*intl.Translation{
ticketStatusExpiredID: {T: "expired"},
ticketStatusUnspentID: {T: "unspent"},
ticketStatusRevokedID: {T: "revoked"},
invalidSeedID: {T: "Invalid seed"},
passwordResetSuccessMsgID: {T: "Your password reset was successful. You can proceed to login with your new password."},
browserNtfnEnabledID: {T: "Bison Wallet notifications enabled"},
browserNtfnOrdersID: {T: "Orders"},
Expand Down Expand Up @@ -611,7 +609,6 @@ var plPL = map[string]*intl.Translation{
txFeeSupportedID: {T: "szacowanie opłat dla tego rodzaju portfela nie jest wspierane"},
matchStatusRedeemPendingID: {T: "Wykup środków w toku"},
passwordResetSuccessMsgID: {T: "Hasło zostało zresetowane pomyślnie. Możesz zalogować się z użyciem nowego hasła."},
invalidSeedID: {T: "Nieprawidłowe ziarno"},
depthLoadingID: {T: "pobieranie danych o głębokości"},
txTypeApproveTokenID: {T: "Zatwierdź token"},
txTypeSendID: {T: "Wyślij"},
Expand Down Expand Up @@ -839,7 +836,6 @@ var ar = map[string]*intl.Translation{
browserNtfnMatchesID: {T: "التطابقات"},
noCexID: {T: "اختر منصة مبادلات للمراجحة"},
walletRecoverySupportMsgID: {T: "فشل تحميل محفظة {{ walletSymbol }} الأصلية بشكل صحيح. حاول النقر على زر 'استعادة' أدناه لإصلاحها"},
invalidSeedID: {T: "بذرة غير صحيحة"},
invalidCompsValueID: {T: "قيمة المقارنات غير صحيحة"},
immatureBalMsgID: {T: "الأموال الواردة في انتظار التأكيد"},
archivedRecordsPathID: {T: "موقع الملف: {{ path }}"},
Expand Down
8 changes: 2 additions & 6 deletions client/webserver/site/src/js/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1977,15 +1977,10 @@ export class AppPassResetForm {
return
}

const seed = page.seedInput.value?.replace(/\s+/g, '') // strip whitespace
if (!seed || seed.length !== 128 /* 64 bytes hex encoded value, check and fail early */) {
Doc.showFormError(page.appPWResetErrMsg, intl.prep(intl.ID_INVALID_SEED))
return
}
const loaded = app().loading(this.form)
const res = await postJSON('/api/resetapppassword', {
newPass: newAppPW,
seed
seed: page.seedInput.value
})
loaded()
if (!app().checkResponse(res)) {
Expand All @@ -2007,6 +2002,7 @@ export class AppPassResetForm {
const page = this.page
page.newAppPassword.value = ''
page.confirmNewAppPassword.value = ''
page.seedInput.value = ''
Doc.hide(page.appPWResetSuccessMsg, page.appPWResetErrMsg)
}
}
Expand Down
3 changes: 1 addition & 2 deletions client/webserver/site/src/js/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ export const ID_TICKET_STATUS_MISSED = 'TICKET_STATUS_MISSED'
export const ID_TICKET_STATUS_EXPIRED = 'TICKET_STATUS_EXPIRED'
export const ID_TICKET_STATUS_UNSPENT = 'TICKET_STATUS_UNSPENT'
export const ID_TICKET_STATUS_REVOKED = 'TICKET_STATUS_REVOKED'
export const ID_INVALID_SEED = 'INVALID_SEED'
export const ID_PASSWORD_RESET_SUCCESS_MSG = 'PASSWORD_RESET_SUCCESS_MSG '
export const ID_PASSWORD_RESET_SUCCESS_MSG = 'PASSWORD_RESET_SUCCESS_MSG'
export const ID_BROWSER_NTFN_ENABLED = 'BROWSER_NTFN_ENABLED'
export const ID_BROWSER_NTFN_ORDERS = 'BROWSER_NTFN_ORDERS'
export const ID_BROWSER_NTFN_MATCHES = 'BROWSER_NTFN_MATCHES'
Expand Down
5 changes: 4 additions & 1 deletion client/webserver/site/src/js/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export default class LoginPage extends BasePage {
prepAndDisplayLoginForm()

this.appPassResetForm = new AppPassResetForm(page.resetAppPWForm, () => { prepAndDisplayLoginForm() })
Doc.bind(page.forgotPassBtn, 'click', () => slideSwap(page.loginForm, page.resetAppPWForm))
Doc.bind(page.forgotPassBtn, 'click', () => {
this.appPassResetForm.refresh()
slideSwap(page.loginForm, page.resetAppPWForm)
})
Doc.bind(page.resetPassFormCloser, 'click', () => { prepAndDisplayLoginForm() })
Doc.bind(page.forms, 'mousedown', (e: MouseEvent) => {
if (!Doc.mouseInElement(e, page.resetAppPWForm) && Doc.isDisplayed(page.resetAppPWForm)) { prepAndDisplayLoginForm() }
Expand Down

0 comments on commit c3ed943

Please sign in to comment.