edit
This commit is contained in:
53
src/app/core/guards/auth.guard.ts
Normal file
53
src/app/core/guards/auth.guard.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { Inject, Injectable, Injector } from '@angular/core';
|
||||||
|
import {
|
||||||
|
ActivatedRouteSnapshot,
|
||||||
|
CanActivate,
|
||||||
|
CanActivateChild,
|
||||||
|
CanLoad,
|
||||||
|
Route,
|
||||||
|
Router,
|
||||||
|
RouterStateSnapshot,
|
||||||
|
UrlSegment,
|
||||||
|
UrlTree
|
||||||
|
} from '@angular/router';
|
||||||
|
import { sysConf } from '@conf/sys.conf';
|
||||||
|
import { CoreService } from '@core';
|
||||||
|
import { ACLGuard, ACLService } from '@delon/acl';
|
||||||
|
import { EAUserService } from '@shared';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
|
||||||
|
const auths = ['YUNLI-CART-SEARCH', 'YUNLI-CART-DAOCHU', 'YUNLI-CART-DETAIL'];
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AuthGuard implements CanActivate, CanActivateChild, CanLoad {
|
||||||
|
constructor(srv: ACLService, router: Router, private eaUserSrv: CoreService, private router2: Router, private inject: Injector) {}
|
||||||
|
canLoad(route: Route, segments: UrlSegment[]): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {
|
||||||
|
throw true;
|
||||||
|
}
|
||||||
|
|
||||||
|
canActivate(route: ActivatedRouteSnapshot, _state: RouterStateSnapshot | null): Observable<boolean> {
|
||||||
|
const canOpen = this.eaUserSrv.loginStatus;
|
||||||
|
if (!canOpen) {
|
||||||
|
this.router2.navigate([sysConf.login_url], {
|
||||||
|
queryParams: {
|
||||||
|
returnUrl: _state?.url
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return of(!canOpen);
|
||||||
|
}
|
||||||
|
return of(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
|
||||||
|
const canOpen = this.eaUserSrv.loginStatus;
|
||||||
|
if (!canOpen) {
|
||||||
|
this.router2.navigate([sysConf.login_url], {
|
||||||
|
queryParams: {
|
||||||
|
returnUrl: state?.url
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return of(!canOpen);
|
||||||
|
}
|
||||||
|
return of(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,7 +13,7 @@ import { environment } from '@env/environment';
|
|||||||
const alainConfig: AlainConfig = {
|
const alainConfig: AlainConfig = {
|
||||||
st: { modal: { size: 'lg' } },
|
st: { modal: { size: 'lg' } },
|
||||||
pageHeader: { homeI18n: 'home', recursiveBreadcrumb: true },
|
pageHeader: { homeI18n: 'home', recursiveBreadcrumb: true },
|
||||||
auth: { login_url: '/passport/login' }
|
auth: { login_url: '/dashboard' }
|
||||||
};
|
};
|
||||||
|
|
||||||
const alainModules = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()];
|
const alainModules = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()];
|
||||||
|
|||||||
@ -112,7 +112,7 @@ export class UserCenterComponentsDriverComponent implements OnInit {
|
|||||||
nzComponentParams: {
|
nzComponentParams: {
|
||||||
isCanCreate: true,
|
isCanCreate: true,
|
||||||
url: '/api/fcc/accountBalance/getDriverAccountDetailByOperator',
|
url: '/api/fcc/accountBalance/getDriverAccountDetailByOperator',
|
||||||
params: { accountType: 2, roleId: item.appUserId, ctfId: item.identityNo }
|
params: { accountType: 2, roleId: item.appUserId, ctfId: item.identityNo, clientName: item.name }
|
||||||
},
|
},
|
||||||
nzFooter: null
|
nzFooter: null
|
||||||
});
|
});
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export class FreightComponentsListComponent implements OnInit {
|
|||||||
nzComponentParams: {
|
nzComponentParams: {
|
||||||
isCanCreate: true,
|
isCanCreate: true,
|
||||||
url: '/api/fcc/accountBalance/getShipperAccountBalanceDetailByOperator',
|
url: '/api/fcc/accountBalance/getShipperAccountBalanceDetailByOperator',
|
||||||
params: { accountType: 1, roleId: item.adminAppUserId, ctfId: item.unifiedSocialCreditCode }
|
params: { accountType: 1, roleId: item.adminAppUserId, ctfId: item.unifiedSocialCreditCode, clientName: item.enterpriseName }
|
||||||
},
|
},
|
||||||
nzFooter: null
|
nzFooter: null
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user