Use loginService to get and set remember email values (#3941)

This commit is contained in:
Robyn MacCallum 2022-11-11 14:15:45 -05:00 committed by GitHub
parent af2e03bdf8
commit 8d128b01b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import { CryptoFunctionService } from "@bitwarden/common/abstractions/cryptoFunc
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/abstractions/log.service";
import { LoginService } from "@bitwarden/common/abstractions/login.service";
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { ValidationService } from "@bitwarden/common/abstractions/validation.service";
@ -23,6 +24,8 @@ import { PasswordlessCreateAuthRequest } from "@bitwarden/common/models/request/
import { AuthRequestResponse } from "@bitwarden/common/models/response/auth-request.response";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { StateService } from "../../core/state/state.service";
@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
@ -58,13 +61,15 @@ export class LoginWithDeviceComponent
i18nService: I18nService,
platformUtilsService: PlatformUtilsService,
private anonymousHubService: AnonymousHubService,
private validationService: ValidationService
private validationService: ValidationService,
private stateService: StateService,
private loginService: LoginService
) {
super(environmentService, i18nService, platformUtilsService);
const navigation = this.router.getCurrentNavigation();
if (navigation) {
this.email = navigation.extras?.state?.email;
this.email = this.loginService.getEmail();
}
//gets signalR push notification
@ -137,6 +142,7 @@ export class LoginWithDeviceComponent
this.router.navigate([this.forcePasswordResetRoute]);
}
} else {
await this.setRememberEmailValues();
if (this.onSuccessfulLogin != null) {
this.onSuccessfulLogin();
}
@ -196,4 +202,12 @@ export class LoginWithDeviceComponent
localHashedPassword
);
}
private async setRememberEmailValues() {
const rememberEmail = this.loginService.getRememberEmail();
const rememberedEmail = this.loginService.getEmail();
await this.stateService.setRememberEmail(rememberEmail);
await this.stateService.setRememberedEmail(rememberEmail ? rememberedEmail : null);
this.loginService.clearValues();
}
}

View File

@ -207,8 +207,8 @@ export class LoginComponent extends BaseLoginComponent implements OnInit, OnDest
return;
}
const email = this.formGroup.get("email").value;
this.router.navigate(["/login-with-device"], { state: { email: email } });
this.setFormValues();
this.router.navigate(["/login-with-device"]);
}
private getPasswordStrengthUserInput() {