mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Migrate to SRP and add change password dialog
Summary: Moves some auth-related UI components, like MFAConfig, out of core, and adds a new ChangePasswordDialog component for allowing direct password changes, replacing the old reset password link to hosted Cognito. Updates all MFA endpoints to use SRP for authentication. Also refactors MFAConfig into smaller files, and polishes up some parts of the UI to be more consistent with the login pages. Test Plan: New server and deployment tests. Updated existing tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3311
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {reportError} from 'app/client/models/errors';
|
||||
import {ApiError} from 'app/common/ApiError';
|
||||
import {BaseAPI} from 'app/common/BaseAPI';
|
||||
import {dom, Observable} from 'grainjs';
|
||||
|
||||
@@ -52,3 +53,20 @@ export function formDataToObj(formElem: HTMLFormElement): { [key: string]: strin
|
||||
export async function submitForm(fields: { [key: string]: string }, form: HTMLFormElement): Promise<any> {
|
||||
return BaseAPI.requestJson(form.action, {method: 'POST', body: JSON.stringify(fields)});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error details on `errObs` if `err` is a 4XX error (except 401). Otherwise, reports the
|
||||
* error via the Notifier instance.
|
||||
*/
|
||||
export function handleFormError(err: unknown, errObs: Observable<string|null>) {
|
||||
if (
|
||||
err instanceof ApiError &&
|
||||
err.status !== 401 &&
|
||||
err.status >= 400 &&
|
||||
err.status < 500
|
||||
) {
|
||||
errObs.set(err.details?.userError ?? err.message);
|
||||
} else {
|
||||
reportError(err as Error|string);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user