ユーザーの役割が異なり、ログインしたユーザーの役割に基づいて、ログイン後に既定のページ(ランディングページ)を変更したいうユーザー役割に基づく動的ランディングページ「〜3.4.0」
私は
import { Routes, RouterModule } from "@angular/router";
import { CashierRiskProfileComponent } from "./cashierriskprofile.component";
const cashierRiskProfileRoutes: Routes = [
{ path: "", redirectTo: "cashierriskprofile", pathMatch: "full" },
{ path: "cashierriskprofile", component: CashierRiskProfileComponent }
];
export const CashierRiskProfileRouting = RouterModule.forChild(cashierRiskProfileRoutes);
コード上記の二つのモジュールExceptionDashboardとcashierRiskprofileモジュールのルートを持っている:それを達成、私を、オンラインリソースを見つけ、それはまだ実装する必要のあるものですか私は何かが欠けていませんでしたcashierRiskprofileとしてデフォルトルートを持っています。
ExceptionDashboard:管理者ユーザーの場合
const exceptionDashboardRoutes: Routes = [
{ path: "exceptionDashboard", component: ExceptionDashboardComponent, pathMatch: 'full' },
{ path: "exceptionDetail", component: ExceptionDetailComponent, pathMatch: 'full' },
{ path: "exceptionTransaction", component: ExceptionTransactionComponent, pathMatch: 'full' }
];
私たちは、私はランディングページとしてexceptionDashboardパスを見せたかった他のユーザーのために、すでにデフォルト設定されたランディングページとしてCashierRiskProfileを示しました。 UserRoleに基づいてどのように変更するのですか?
私はCanActivateViaAuthGuard "canActivate"サービスを実装して、ユーザーが弁護されていない場合に特定のページにリダイレクトする方法を知っていますが、ユーザーの役割に基づいてランディングページを変更することを検討していますか?
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
//import { AuthService } from './auth.service';
@Injectable()
export class CanActivateViaAuthGuard implements CanActivate {
constructor(/*private authService: AuthService*/) { }
canActivate() {
//if logged in return true
return true;
//else retrun to login page
//return false;
}
}
ユーザーロールに基づいて動的なデフォルトページを変更するものを実装したいと考えています。
は、これはまだ、関連しますか? http://stackoverflow.com/questions/38402776/angular2-routing-canactivate-and-authguard-jwt-with-user-role-parameter –