mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Initial work
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||
import { FormBuilder, Validators } from "@angular/forms";
|
||||
import { Router } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
|
||||
@@ -20,6 +20,9 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
private destroyed$: Subject<void> = new Subject();
|
||||
|
||||
loginInitiated = false;
|
||||
//use this to redirect somehwere else after login
|
||||
redirectPath: string;
|
||||
sessionId: string;
|
||||
formGroup = this.formBuilder.group({
|
||||
email: ["", [Validators.required, Validators.email]],
|
||||
rememberEmail: [false],
|
||||
@@ -32,10 +35,16 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
private router: Router,
|
||||
private i18nService: I18nService,
|
||||
private environmentService: EnvironmentService,
|
||||
private loginService: LoginService
|
||||
private loginService: LoginService,
|
||||
protected route: ActivatedRoute
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
this.route?.queryParams.pipe(takeUntil(this.destroyed$)).subscribe((params) => {
|
||||
this.redirectPath = params?.redirectPath;
|
||||
this.sessionId = params?.sessionId;
|
||||
});
|
||||
|
||||
let savedEmail = this.loginService.getEmail();
|
||||
const rememberEmail = this.loginService.getRememberEmail();
|
||||
|
||||
@@ -80,7 +89,14 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.loginService.setEmail(this.formGroup.value.email);
|
||||
this.loginService.setRememberEmail(this.formGroup.value.rememberEmail);
|
||||
this.router.navigate(["login"], { queryParams: { email: this.formGroup.value.email } });
|
||||
|
||||
this.router.navigate(["login"], {
|
||||
queryParams: {
|
||||
email: this.formGroup.value.email,
|
||||
redirectPath: this.redirectPath,
|
||||
sessionId: this.sessionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
get selfHostedDomain() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, NgZone } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component";
|
||||
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
|
||||
@@ -50,7 +50,8 @@ export class LockComponent extends BaseLockComponent {
|
||||
policyService: InternalPolicyService,
|
||||
passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||
private authService: AuthService,
|
||||
dialogService: DialogServiceAbstraction
|
||||
dialogService: DialogServiceAbstraction,
|
||||
route: ActivatedRoute
|
||||
) {
|
||||
super(
|
||||
router,
|
||||
@@ -69,7 +70,8 @@ export class LockComponent extends BaseLockComponent {
|
||||
policyApiService,
|
||||
policyService,
|
||||
passwordStrengthService,
|
||||
dialogService
|
||||
dialogService,
|
||||
route
|
||||
);
|
||||
this.successRoute = "/tabs/current";
|
||||
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
||||
|
||||
@@ -532,6 +532,7 @@ export default class MainBackground {
|
||||
this.fido2AuthenticatorService = new Fido2AuthenticatorService(
|
||||
this.cipherService,
|
||||
this.fido2UserInterfaceService,
|
||||
this.authService,
|
||||
this.logService
|
||||
);
|
||||
this.fido2ClientService = new Fido2ClientService(
|
||||
|
||||
@@ -94,6 +94,14 @@ export type BrowserFido2Message = { sessionId: string } & (
|
||||
type: "AbortResponse";
|
||||
fallbackRequested: boolean;
|
||||
}
|
||||
| {
|
||||
type: "LogInRequest";
|
||||
userVerification: boolean;
|
||||
}
|
||||
| {
|
||||
type: "LogInResponse";
|
||||
userVerified: boolean;
|
||||
}
|
||||
);
|
||||
|
||||
export class BrowserFido2UserInterfaceService implements Fido2UserInterfaceServiceAbstraction {
|
||||
@@ -272,6 +280,19 @@ export class BrowserFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
await this.receive("AbortResponse");
|
||||
}
|
||||
|
||||
async login(userVerification: boolean): Promise<{ userVerified: boolean }> {
|
||||
const data: BrowserFido2Message = {
|
||||
type: "LogInRequest",
|
||||
userVerification,
|
||||
sessionId: this.sessionId,
|
||||
};
|
||||
|
||||
await this.send(data);
|
||||
const response = await this.receive("LogInResponse");
|
||||
|
||||
return { userVerified: response.userVerified };
|
||||
}
|
||||
|
||||
async close() {
|
||||
this.popupUtilsService.closePopOut(this.popout);
|
||||
this.closed = true;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { Fido2KeyView } from "@bitwarden/common/vault/models/view/fido2-key.view";
|
||||
|
||||
import { BrowserApi } from "../../../../platform/browser/browser-api";
|
||||
import { PopupUtilsService } from "../../../../popup/services/popup-utils.service";
|
||||
import {
|
||||
BrowserFido2Message,
|
||||
BrowserFido2UserInterfaceSession,
|
||||
@@ -48,7 +49,8 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private cipherService: CipherService,
|
||||
private passwordRepromptService: PasswordRepromptService
|
||||
private passwordRepromptService: PasswordRepromptService,
|
||||
private popupUtils: PopupUtilsService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -61,6 +63,19 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(([sessionId, message]) => {
|
||||
this.sessionId = sessionId;
|
||||
if (message.type === "LogInRequest") {
|
||||
//route to login
|
||||
const url = chrome.extension.getURL(
|
||||
`popup/index.html#/home?sessionId=${sessionId}&redirectPath=fido2&uilocation=popout`
|
||||
);
|
||||
// BrowserApi.createNewWindow(url);
|
||||
BrowserApi.createNewTab(url);
|
||||
// if (this.popupUtils.inPopup(window)) {
|
||||
// BrowserApi.closePopup(window);
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.type === "NewSessionCreatedRequest" && message.sessionId !== sessionId) {
|
||||
return this.abort(false);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class LockComponent extends BaseLockComponent {
|
||||
environmentService: EnvironmentService,
|
||||
protected override stateService: ElectronStateService,
|
||||
apiService: ApiService,
|
||||
private route: ActivatedRoute,
|
||||
route: ActivatedRoute,
|
||||
private broadcasterService: BroadcasterService,
|
||||
ngZone: NgZone,
|
||||
policyApiService: PolicyApiServiceAbstraction,
|
||||
@@ -71,7 +71,8 @@ export class LockComponent extends BaseLockComponent {
|
||||
policyApiService,
|
||||
policyService,
|
||||
passwordStrengthService,
|
||||
dialogService
|
||||
dialogService,
|
||||
route
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, NgZone } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import { LockComponent as BaseLockComponent } from "@bitwarden/angular/auth/components/lock.component";
|
||||
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
|
||||
@@ -43,7 +43,8 @@ export class LockComponent extends BaseLockComponent {
|
||||
policyApiService: PolicyApiServiceAbstraction,
|
||||
policyService: InternalPolicyService,
|
||||
passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||
dialogService: DialogServiceAbstraction
|
||||
dialogService: DialogServiceAbstraction,
|
||||
route: ActivatedRoute
|
||||
) {
|
||||
super(
|
||||
router,
|
||||
@@ -62,7 +63,8 @@ export class LockComponent extends BaseLockComponent {
|
||||
policyApiService,
|
||||
policyService,
|
||||
passwordStrengthService,
|
||||
dialogService
|
||||
dialogService,
|
||||
route
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user