mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-01 08:00:47 +08:00
Add navigating away check before login wizard completed
This commit is contained in:
parent
e806a35660
commit
36a2f16fd5
5 changed files with 58 additions and 9 deletions
|
@ -72,13 +72,25 @@ export class AuthGuard {
|
|||
this.authorizeUserACL(route)
|
||||
]).pipe(map(([session, acl]: any) => {
|
||||
|
||||
|
||||
|
||||
if (session instanceof UrlTree) {
|
||||
return session;
|
||||
}
|
||||
if (acl instanceof UrlTree) {
|
||||
return acl;
|
||||
}
|
||||
return session && acl;
|
||||
if (session && acl) {
|
||||
const isLoginWizardCompleted = this.appState.getLoginWizardComplete();
|
||||
|
||||
if (!isLoginWizardCompleted && snapshot.url !== '/users/Wizard') {
|
||||
return this.router.parseUrl('/users/Wizard');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
));
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ export interface SessionStatus {
|
|||
export interface AppStatus {
|
||||
installed?: boolean;
|
||||
locked?: boolean;
|
||||
loginWizardCompleted?: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
|
@ -370,6 +371,9 @@ export class AuthService {
|
|||
take(1),
|
||||
map((user: SessionStatus) => {
|
||||
|
||||
const isLoginWizardCompleted = user.appStatus.loginWizardCompleted ?? false;
|
||||
this.appStateStore.setLoginWizardComplete(isLoginWizardCompleted);
|
||||
|
||||
if (user && user.appStatus.installed === false) {
|
||||
return this.router.parseUrl('install');
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* the words "Supercharged by SuiteCRM".
|
||||
*/
|
||||
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
import {Injectable, signal, WritableSignal} from '@angular/core';
|
||||
import {BehaviorSubject, combineLatestWith, Observable, Subscription} from 'rxjs';
|
||||
import {distinctUntilChanged, map} from 'rxjs/operators';
|
||||
import {isVoid} from '../../common/utils/value-utils';
|
||||
|
@ -94,7 +94,7 @@ export class AppStateStore implements StateStore {
|
|||
protected loadingBuffer: LoadingBuffer;
|
||||
protected subs: Subscription[] = [];
|
||||
|
||||
isTouchScreen = signal<boolean>(false);
|
||||
private isLoginWizardCompleted: WritableSignal<boolean> = signal<boolean>(true);
|
||||
|
||||
constructor(
|
||||
protected loadingBufferFactory: LoadingBufferFactory,
|
||||
|
@ -122,12 +122,6 @@ export class AppStateStore implements StateStore {
|
|||
|
||||
}))
|
||||
);
|
||||
|
||||
if('ontouchstart' in window || navigator.maxTouchPoints > 0) {
|
||||
this.isTouchScreen.set(true);
|
||||
} else {
|
||||
this.isTouchScreen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,4 +453,12 @@ export class AppStateStore implements StateStore {
|
|||
public resetActiveDropdown(): void {
|
||||
this.updateState({...internalState, activeNavbarDropdown: 0});
|
||||
}
|
||||
|
||||
public setLoginWizardComplete(isComplete: boolean): void {
|
||||
this.isLoginWizardCompleted.set(isComplete);
|
||||
}
|
||||
|
||||
public getLoginWizardComplete(): boolean {
|
||||
return this.isLoginWizardCompleted();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,6 +277,14 @@ class SecurityController extends AbstractController
|
|||
return $response;
|
||||
}
|
||||
|
||||
$isLoginWizardCompleteStatus = $this->authentication->getLoginWizardCompletedStatus();
|
||||
|
||||
if ($isLoginWizardCompleteStatus) {
|
||||
$appStatus['loginWizardCompleted'] = true;
|
||||
} else {
|
||||
$appStatus['loginWizardCompleted'] = false;
|
||||
}
|
||||
|
||||
$data = $this->getResponseData($user, $appStatus);
|
||||
|
||||
if (!isset($data['redirect'])){
|
||||
|
|
|
@ -145,6 +145,29 @@ class Authentication extends LegacyHandler
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user completed login wizard
|
||||
* @return bool
|
||||
*/
|
||||
public function getLoginWizardCompletedStatus(): bool
|
||||
{
|
||||
|
||||
$this->init();
|
||||
|
||||
$user = $this->userHandler->getCurrentUser();
|
||||
|
||||
$ut = $user->getPreference('ut') ?? '';
|
||||
|
||||
$this->close();
|
||||
|
||||
if (empty($ut)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init legacy user session
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue