1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-03 08:49:50 +01:00

private mode component

This commit is contained in:
Kyle Spearrin 2018-04-13 22:08:24 -04:00
parent 31ddb97530
commit 4308947893
9 changed files with 62 additions and 10 deletions

View File

@ -18,6 +18,7 @@ import { TwoFactorOptionsComponent } from './accounts/two-factor-options.compone
import { TwoFactorComponent } from './accounts/two-factor.component'; import { TwoFactorComponent } from './accounts/two-factor.component';
import { PasswordGeneratorHistoryComponent } from './generator/password-generator-history.component'; import { PasswordGeneratorHistoryComponent } from './generator/password-generator-history.component';
import { PasswordGeneratorComponent } from './generator/password-generator.component'; import { PasswordGeneratorComponent } from './generator/password-generator.component';
import { PrivateModeComponent } from './private-mode.component';
import { ExportComponent } from './settings/export.component'; import { ExportComponent } from './settings/export.component';
import { FolderAddEditComponent } from './settings/folder-add-edit.component'; import { FolderAddEditComponent } from './settings/folder-add-edit.component';
import { FoldersComponent } from './settings/folders.component'; import { FoldersComponent } from './settings/folders.component';
@ -175,6 +176,11 @@ const routes: Routes = [
canActivate: [AuthGuardService], canActivate: [AuthGuardService],
data: { state: 'options' }, data: { state: 'options' },
}, },
{
path: 'private-mode',
component: PrivateModeComponent,
data: { state: 'private-mode' },
},
{ {
path: 'tabs', path: 'tabs',
component: TabsComponent, component: TabsComponent,

View File

@ -1,3 +1,5 @@
import { BrowserApi } from '../browser/browserApi';
import { import {
ToasterConfig, ToasterConfig,
ToasterContainerComponent, ToasterContainerComponent,
@ -65,6 +67,10 @@ export class AppComponent implements OnInit {
private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { } private changeDetectorRef: ChangeDetectorRef, private ngZone: NgZone) { }
ngOnInit() { ngOnInit() {
if (BrowserApi.getBackgroundPage() == null) {
return;
}
this.ngZone.runOutsideAngular(() => { this.ngZone.runOutsideAngular(() => {
window.onmousemove = () => this.recordActivity(); window.onmousemove = () => this.recordActivity();
window.onmousedown = () => this.recordActivity(); window.onmousedown = () => this.recordActivity();

View File

@ -14,8 +14,6 @@ import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { EnvironmentComponent } from './accounts/environment.component'; import { EnvironmentComponent } from './accounts/environment.component';
import { HintComponent } from './accounts/hint.component'; import { HintComponent } from './accounts/hint.component';
import { HomeComponent } from './accounts/home.component'; import { HomeComponent } from './accounts/home.component';
@ -24,8 +22,10 @@ import { LoginComponent } from './accounts/login.component';
import { RegisterComponent } from './accounts/register.component'; import { RegisterComponent } from './accounts/register.component';
import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component'; import { TwoFactorOptionsComponent } from './accounts/two-factor-options.component';
import { TwoFactorComponent } from './accounts/two-factor.component'; import { TwoFactorComponent } from './accounts/two-factor.component';
import { AppComponent } from './app.component';
import { PasswordGeneratorHistoryComponent } from './generator/password-generator-history.component'; import { PasswordGeneratorHistoryComponent } from './generator/password-generator-history.component';
import { PasswordGeneratorComponent } from './generator/password-generator.component'; import { PasswordGeneratorComponent } from './generator/password-generator.component';
import { PrivateModeComponent } from './private-mode.component';
import { ExportComponent } from './settings/export.component'; import { ExportComponent } from './settings/export.component';
import { FolderAddEditComponent } from './settings/folder-add-edit.component'; import { FolderAddEditComponent } from './settings/folder-add-edit.component';
import { FoldersComponent } from './settings/folders.component'; import { FoldersComponent } from './settings/folders.component';
@ -102,6 +102,7 @@ import { IconComponent } from 'jslib/angular/components/icon.component';
PasswordGeneratorHistoryComponent, PasswordGeneratorHistoryComponent,
PopOutComponent, PopOutComponent,
PremiumComponent, PremiumComponent,
PrivateModeComponent,
RegisterComponent, RegisterComponent,
SearchCiphersPipe, SearchCiphersPipe,
SettingsComponent, SettingsComponent,
@ -113,9 +114,7 @@ import { IconComponent } from 'jslib/angular/components/icon.component';
TwoFactorComponent, TwoFactorComponent,
ViewComponent, ViewComponent,
], ],
entryComponents: [ entryComponents: [],
],
providers: [], providers: [],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })

View File

@ -0,0 +1,6 @@
<div class="content">
<p class="text-center">{{privateModeMessage}}</p>
<button type="button" class="btn primary block" (click)="learnMore()">
<b>{{learnMoreMessage}}</b>
</button>
</div>

View File

@ -0,0 +1,24 @@
import { BrowserApi } from '../browser/browserApi';
import {
Component,
OnInit,
} from '@angular/core';
@Component({
selector: 'app-private-mode',
templateUrl: 'private-mode.component.html',
})
export class PrivateModeComponent implements OnInit {
privateModeMessage: string;
learnMoreMessage: string;
ngOnInit() {
this.privateModeMessage = chrome.i18n.getMessage('privateModeMessage');
this.learnMoreMessage = chrome.i18n.getMessage('learnMore');
}
learnMore() {
BrowserApi.createNewTab('https://help.bitwarden.com/article/extension-wont-load-in-private-mode/');
}
}

View File

@ -76,6 +76,10 @@ textarea {
resize: vertical; resize: vertical;
} }
main {
height: 100%;
}
content::-webkit-scrollbar { content::-webkit-scrollbar {
width: 10px; width: 10px;
height: 10px; height: 10px;

View File

@ -1,3 +1,5 @@
import { BrowserApi } from '../../browser/browserApi';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
CanActivate, CanActivate,
@ -12,6 +14,11 @@ export class LaunchGuardService implements CanActivate {
constructor(private cryptoService: CryptoService, private userService: UserService, private router: Router) { } constructor(private cryptoService: CryptoService, private userService: UserService, private router: Router) { }
async canActivate() { async canActivate() {
if (BrowserApi.getBackgroundPage() == null) {
this.router.navigate(['private-mode']);
return false;
}
const isAuthed = await this.userService.isAuthenticated(); const isAuthed = await this.userService.isAuthenticated();
if (!isAuthed) { if (!isAuthed) {
return true; return true;

View File

@ -73,10 +73,10 @@ export function initFactory(i18nService: I18nService, storageService: StorageSer
window.document.body.classList.add('body-sm'); window.document.body.classList.add('body-sm');
} }
if (BrowserApi.getBackgroundPage() != null) {
stateService.save(ConstantsService.disableFaviconKey, stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey)); await storageService.get<boolean>(ConstantsService.disableFaviconKey));
if (BrowserApi.getBackgroundPage() != null) {
window.document.documentElement.classList.add('locale_' + i18nService.translationLocale); window.document.documentElement.classList.add('locale_' + i18nService.translationLocale);
authService.init(); authService.init();

View File

@ -30,8 +30,8 @@
<app-ciphers-list [ciphers]="loginCiphers" title="{{'autoFill' | i18n}}" [showView]="true" <app-ciphers-list [ciphers]="loginCiphers" title="{{'autoFill' | i18n}}" [showView]="true"
(onSelected)="fillCipher($event)" (onView)="viewCipher($event)" (onSelected)="fillCipher($event)" (onView)="viewCipher($event)"
*ngIf="loginCiphers.length"></app-ciphers-list> *ngIf="loginCiphers.length"></app-ciphers-list>
<div class="box-content-row text-center padded no-hover" *ngIf="!loginCiphers.length"> <div class="box-content-row padded no-hover" *ngIf="!loginCiphers.length">
<p>{{'autoFillInfo' | i18n}}</p> <p class="text-center">{{'autoFillInfo' | i18n}}</p>
<button type="button" class="btn primary link block" (click)="addCipher()"> <button type="button" class="btn primary link block" (click)="addCipher()">
{{'addLogin' | i18n}} {{'addLogin' | i18n}}
</button> </button>