我创建了angualar 2 firebase项目,该项目能够添加删除编辑帖子。使用firebase gmail身份验证进行身份验证。这对于这一点非常有用。但我想创建管理员,他可以看到帖子。当我输入myexample时。 com / admin我想去同一个站点的管理页面,管理员页面应该是电子邮件验证。但是当我输入那个url(myexample.com/admin)用户登录页面display.im newbie to web development。
my routes.ts
const routes: Routes = [
{ path: '', redirectTo:'main', pathMatch: 'full'},
{ path:'login',component:LoginComponent},
{ path:'admin',component: AdminLoginComponent},
{ path: 'main', component:AdminBodyComponent },
{ path: 'adminpanel', component:AdminComponent },
{ path: 'posts',component:PostsComponent},
{ path: 'addposts',component:AddPostComponent},
{ path: 'editposts/:id',component:EditpostComponent}
];
app.component.ts
this.authService.af.auth.subscribe((auth)=>{
if(auth == null && this.router.url != '/admin'){
//not logged int
this.isLoggedIn =false;
this.displayName='';
this.userMail='';
this.router.navigate(['login']);
}else if(this.router.url == 'admin'){
this.isAdmin=true;
this.router.navigate(['admin']);
}
else{
//logged in
this.isLoggedIn=true;
this.displayName=auth.google.displayName;
this.userMail=auth.google.email;
this.router.navigate([''])
}
})
}