1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

safari duo support

This commit is contained in:
Kyle Spearrin 2018-04-04 16:53:41 -04:00
parent a6b87bf501
commit 9a1a7d33be
3 changed files with 42 additions and 2 deletions

2
jslib

@ -1 +1 @@
Subproject commit 013bf20a35c74383389337ac2c5ae9ac19a0bba7 Subproject commit fd19efa9f260addca1f0fc14dd1641a276a22759

View File

@ -75,7 +75,10 @@
</ng-container> </ng-container>
<ng-container *ngIf="selectedProviderType === providerType.Duo || <ng-container *ngIf="selectedProviderType === providerType.Duo ||
selectedProviderType === providerType.OrganizationDuo"> selectedProviderType === providerType.OrganizationDuo">
<div id="duo-frame"><iframe id="duo_iframe"></iframe></div> <div id="duo-frame" *ngIf="!showNewWindowMessage"><iframe id="duo_iframe"></iframe></div>
<div *ngIf="showNewWindowMessage" class="content no-vpad text-center">
{{'twoStepNewWindowMessage' | i18n}}
</div>
<div class="box"> <div class="box">
<div class="box-content"> <div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow> <div class="box-content-row box-content-row-checkbox" appBoxRow>

View File

@ -7,6 +7,10 @@ import { Router } from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2'; import { Angulartics2 } from 'angulartics2';
import { BrowserApi } from '../../browser/browserApi';
import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
import { AuthService } from 'jslib/abstractions/auth.service'; import { AuthService } from 'jslib/abstractions/auth.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { EnvironmentService } from 'jslib/abstractions/environment.service';
@ -21,6 +25,8 @@ import { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib/angular/comp
template: template, template: template,
}) })
export class TwoFactorComponent extends BaseTwoFactorComponent { export class TwoFactorComponent extends BaseTwoFactorComponent {
showNewWindowMessage = false;
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService, analytics: Angulartics2, toasterService: ToasterService,
i18nService: I18nService, apiService: ApiService, i18nService: I18nService, apiService: ApiService,
@ -30,6 +36,37 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
platformUtilsService, syncService, window, environmentService); platformUtilsService, syncService, window, environmentService);
} }
async ngOnInit() {
this.showNewWindowMessage = this.platformUtilsService.isSafari();
await super.ngOnInit();
if (this.selectedProviderType == null) {
return;
}
var isDuo = this.selectedProviderType == TwoFactorProviderType.Duo ||
this.selectedProviderType == TwoFactorProviderType.OrganizationDuo;
if (!this.platformUtilsService.isSafari() || !isDuo) {
return;
}
const params = this.authService.twoFactorProviders.get(this.selectedProviderType);
const tab = BrowserApi.createNewTab(BrowserApi.getAssetUrl('2fa/index.html'));
const tabToSend = BrowserApi.makeTabObject(tab);
window.setTimeout(() => {
BrowserApi.tabSendMessage(tabToSend, {
command: '2faPageData',
data: {
type: 'duo',
host: params.Host,
signature: params.Signature,
}
});
}, 500);
// TODO: listen for duo data message response
}
anotherMethod() { anotherMethod() {
this.router.navigate(['2fa-options']); this.router.navigate(['2fa-options']);
} }