Implemented feedback

This commit is contained in:
Matt Smith 2020-08-14 15:20:16 -05:00
parent 2d56510f0e
commit 3b560fca22
4 changed files with 24 additions and 48 deletions

View File

@ -4,7 +4,6 @@ import { CipherView } from 'jslib/models/view/cipherView';
import { LoginUriView } from 'jslib/models/view/loginUriView';
import { LoginView } from 'jslib/models/view/loginView';
import { AuthResult } from 'jslib/models/domain/authResult';
import { AuthService } from 'jslib/abstractions/auth.service';
import { AutofillService } from '../services/abstractions/autofill.service';
import BrowserPlatformUtilsService from '../services/browserPlatformUtils.service';
@ -50,30 +49,6 @@ export default class RuntimeBackground {
this.onInstalledReason = details.reason;
});
}
chrome.runtime.onMessage.addListener(
(request: any) => {
var vaultUrl = environmentService.webVaultUrl;
if(!vaultUrl) {
vaultUrl = 'https://vault.bitwarden.com';
}
if(!request.referrer) {
return;
}
if(!vaultUrl.includes(request.referrer)) {
return;
}
if (request.type == "AUTH_RESULT") {
try {
popupUtilsService.ProcessSso(request.code, request.state);
}
catch (error) { }
}
});
}
async init() {
@ -189,6 +164,27 @@ export default class RuntimeBackground {
break;
}
break;
case 'authResult':
var vaultUrl = this.environmentService.webVaultUrl;
if(!vaultUrl) {
vaultUrl = 'https://vault.bitwarden.com';
}
if(!msg.referrer) {
return;
}
if(!vaultUrl.includes(msg.referrer)) {
return;
}
try {
chrome.tabs.create({
url: 'popup/index.html?uilocation=popout#/sso?code=' + msg.code + '&state=' + msg.state
});
}
catch { }
break;
default:
break;
}

View File

@ -2,9 +2,9 @@ window.addEventListener("message", function(event) {
if (event.source != window)
return;
if (event.data.type && (event.data.type == "AUTH_RESULT")) {
if (event.data.command && (event.data.command == "authResult")) {
chrome.runtime.sendMessage({
type: event.data.type,
command: event.data.command,
code: event.data.code,
state: event.data.state,
referrer: event.source.location.hostname

View File

@ -9,7 +9,6 @@ import { ApiService } from 'jslib/abstractions/api.service';
import { AuthService } from 'jslib/abstractions/auth.service';
import BrowserPlatformUtilsService from '../../services/browserPlatformUtils.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { ConstantsService } from 'jslib/services/constants.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
@ -30,8 +29,7 @@ export class SsoComponent extends BaseSsoComponent {
storageService: StorageService, stateService: StateService,
platformUtilsService: PlatformUtilsService, apiService: ApiService,
cryptoFunctionService: CryptoFunctionService, passwordGenerationService: PasswordGenerationService,
syncService: SyncService, private browserPlatformUtilsService: BrowserPlatformUtilsService,
private environmentService: EnvironmentService ) {
syncService: SyncService, private environmentService: EnvironmentService ) {
super(authService, router, i18nService, route, storageService, stateService, platformUtilsService,
apiService, cryptoFunctionService, passwordGenerationService);
@ -44,17 +42,7 @@ export class SsoComponent extends BaseSsoComponent {
this.clientId = 'browser';
super.onSuccessfulLogin = () => {
var sidebarName : string = this.browserPlatformUtilsService.sidebarViewName();
var sidebarWindows = chrome.extension.getViews({ type: sidebarName });
if(sidebarWindows && sidebarWindows.length > 0) {
sidebarWindows[0].location.reload();
}
return syncService.fullSync(true);
};
super.onSuccessfulLoginTwoFactorNavigate = () => {
return router.navigate(['2fa']);
}
}
}

View File

@ -78,12 +78,4 @@ export class PopupUtilsService {
// Safari can't open popup in full page tab :(
}
}
ProcessSso(code: string, state: string)
{
// Redirect to SSO token validation.
chrome.tabs.create({
url: 'popup/index.html?uilocation=popout#/sso?code=' + code + '&state=' + state
});
}
}