1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

fix(login): [PM-11502] Support Remember Email option consistently

* Moved saving of SSO email outside of browser/desktop code

* Clarified comments.

* Tests

* Refactored login component services to manage state

* Fixed input on login component

* Fixed tests

* Linting

* Moved web setting in state into web override

* updated tests

* Fixed typing.

* Fixed type safety issues.

* Added comments and renamed for clarity.

* Removed method parameters that weren't used

* Added clarifying comments

* Added more comments.

* Removed test that is not necessary on base

* Test cleanup

* More comments.

* Linting

* Fixed test.

* Fixed base URL

* Fixed typechecking.

* Type checking

* Moved setting of email state to default service

* Added comments.

* Consolidated SSO URL formatting

* Updated comment

* Fixed reference.

* Fixed missing parameter.

* Initialized service.

* Added comments

* Added initialization of new service

* Made email optional due to CLI.

* Fixed comment on handleSsoClick.

* Added SSO email persistence to v1 component.

* Updated login email service.

* Updated setting of remember me

* Removed unnecessary input checking and rearranged functions

* Fixed name

* Added handling of Remember Email to old component for passkey click

* Updated v1 component to persist the email on Continue click

* Fix merge conflicts.

* Merge conflicts in login component.

* Persisted login email on v1 browser component.

* Merge conflicts

* fix(snap) [PM-17464][PM-17463][PM-15587] Allow Snap to use custom callback protocol

* Removed Snap from custom protocol workaround

* Fixed tests.

* Updated case numbers on test

* Resolved PR feedback.

* PM-11502 - LoginEmailSvcAbstraction - mark methods as abstract to satisfy strict ts.

* Removed test

* Changed to persist on leaving fields instead of button click.

* Fixed type checking.

---------

Co-authored-by: Bernd Schoolmann <mail@quexten.com>
Co-authored-by: Jared Snider <jsnider@bitwarden.com>
Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
This commit is contained in:
Todd Martin
2025-04-10 18:58:49 -04:00
committed by GitHub
parent e88813e983
commit f7934b98c6
13 changed files with 241 additions and 295 deletions

View File

@@ -1,43 +1,34 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Observable } from "rxjs";
export abstract class LoginEmailServiceAbstraction {
/**
* An observable that monitors the loginEmail in memory.
* An observable that monitors the loginEmail.
* The loginEmail is the email that is being used in the current login process.
*/
loginEmail$: Observable<string | null>;
abstract loginEmail$: Observable<string | null>;
/**
* An observable that monitors the storedEmail on disk.
* An observable that monitors the remembered email.
* This will return null if an account is being added.
*/
storedEmail$: Observable<string | null>;
abstract rememberedEmail$: Observable<string | null>;
/**
* Sets the loginEmail in memory.
* The loginEmail is the email that is being used in the current login process.
* Consumed through `loginEmail$` observable.
*/
setLoginEmail: (email: string) => Promise<void>;
abstract setLoginEmail: (email: string) => Promise<void>;
/**
* Gets from memory whether or not the email should be stored on disk when `saveEmailSettings` is called.
* @returns A boolean stating whether or not the email should be stored on disk.
* Persist the user's choice of whether to remember their email on subsequent login attempts.
* Consumed through `rememberedEmail$` observable.
*/
getRememberEmail: () => boolean;
abstract setRememberedEmailChoice: (email: string, remember: boolean) => Promise<void>;
/**
* Sets in memory whether or not the email should be stored on disk when `saveEmailSettings` is called.
* Clears the in-progress login email, to be used after a successful login.
*/
setRememberEmail: (value: boolean) => void;
abstract clearLoginEmail: () => Promise<void>;
/**
* Sets the email and rememberEmail properties in memory to null.
* Clears the remembered email.
*/
clearValues: () => void;
/**
* Saves or clears the email on disk
* - If an account is being added, only changes the stored email when rememberEmail is true.
* - If rememberEmail is true, sets the email on disk to the current email.
* - If rememberEmail is false, sets the email on disk to null.
* Always clears the email and rememberEmail properties from memory.
* @returns A promise that resolves once the email settings are saved.
*/
saveEmailSettings: () => Promise<void>;
abstract clearRememberedEmail: () => Promise<void>;
}