import { IpcRendererService } from './electron/ipcrenderer.service' ; import { Injectable } from '@angular/core' ; import { SettingsService } from "@services/settings.service" ; import { CryptService } from "@services/crypt.service" ; import { ApplicationService } from "@services/electron/application.service" ; @ Injectable ( ) export class AuthService { public authRequired : boolean = false ; constructor ( private cryptService , private applicationService , private ipcRendererService , private settingsService ) { this . updateAuthState ( ) ; } public updateAuthState ( ) { this . authRequired = this . requireAuthentification ( ) ; } public loginWithMasterPassword ( masterPassword ) { return new Promise ( ( resolve , reject ) => { if ( this . settingsService . option . vip . multiaccount . master_password == this . cryptService . createHash ( masterPassword ) ) { resolve ( masterPassword ) ; } else if ( this . settingsService . option . vip . multiaccount . master_password == this . cryptService . createHashMd5 ( masterPassword ) ) { this . settingsService . option . vip . multiaccount . master_password = this . cryptService . createHash ( masterPassword ) ; resolve ( masterPassword ) ; } else { reject ( ) ; } } ) ; } public requireAuthentification ( ) { if ( Application . isAuthenticated == false && Application . skipAuthentication == false ) { if ( this . settingsService . option . vip . multiaccount . active && Application . masterPassword == "" ) { return true ; } } return false ; } }