Use loginService to get and set remember email values (#3941)
This commit is contained in:
parent
af2e03bdf8
commit
8d128b01b9
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue