https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/token.service.ts

  set(data: ITokenModel): boolean {
const res = this.store.set(this._options.store_key!, data);
this.change$.next(data);
return res;
}

ITokenModel: https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/interface.ts

export interface ITokenModel {
[key: string]: any; token: string | null | undefined; /**
* 过期时间,单位:ms
* - 不管Simple、JWT模式都必须指定
*/
expired?: number;
}

SimpleGuard:

https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/simple/simple.guard.ts

注入了 TokenService

@Injectable({ providedIn: 'root' })
export class SimpleGuard implements CanActivate, CanActivateChild, CanLoad {
private url?: string; private get cog(): AlainAuthConfig {
return this.srv.options;
} constructor(@Inject(DA_SERVICE_TOKEN) private srv: ITokenService, private injector: Injector) {} private process(): boolean {
const res = CheckSimple(this.srv.get() as SimpleTokenModel);
if (!res) {
ToLogin(this.cog, this.injector, this.url);
}
return res;
} // lazy loading
canLoad(route: Route, _segments: UrlSegment[]): boolean {
this.url = route.path;
return this.process();
}
// all children route
canActivateChild(_childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.url = state.url;
return this.process();
}
// route
canActivate(_route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
this.url = state.url;
return this.process();
}
}

在默认的 src\app\routes\routes-routing.module.ts 中使用了 SimpleGuard 来检查用户是否已经登录。

const routes: Routes = [
{
path: '',
component: LayoutBasicComponent,
canActivate: [startPageGuard, SimpleGuard],
canActivateChild: [SimpleGuard],

JWTGuard

https://github.com/ng-alain/delon/blob/master/packages/auth/src/token/jwt/jwt.guard.ts

TokenService的更多相关文章

  1. atitit.TokenService v3 qb1  token服务模块的设计 新特性.docx

    atitit.TokenService v3 qb1  token服务模块的设计 新特性.docx 1.1. V3 新特性1 1.2. V2 新特性1 2. Token的归类1 3. Token的用途 ...

  2. atitit.TokenService  token服务模块的设计

    atitit.TokenService  token服务模块的设计 1. Token的归类1 2. Token的用途2 2.1. 访问控制2 2.2. 编译原理术语)编辑2 2.3. 数据处理2 1. ...

  3. Spring Security OAuth2 开发指南

    官方原文:http://projects.spring.io/spring-security-oauth/docs/oauth2.html 翻译及修改补充:Alex Liao. 转载请注明来源:htt ...

  4. Atitit. 项目文档目录大纲 总集合  v2

    Atitit. 项目文档目录大纲 总集合  v2 -----Atitti.原有项目源码的架构,框架,配置与环境说明 v3 q511 -----Atitit.开发环境 与 工具 以及技术框架 以及 注意 ...

  5. Web APi之认证(Authentication)两种实现方式后续【三】(十五)

    前言 之前一直在找工作中,过程也是令人着实的心塞,最后还是稳定了下来,博客也停止更新快一个月了,学如逆水行舟,不进则退,之前学的东西没怎么用,也忘记了一点,不过至少由于是切身研究,本质以及原理上的脉络 ...

  6. Atitit 修改密码的功能流程设计 attilax总结

    Atitit 修改密码的功能流程设计 attilax总结 1.1. 注意点1 1.2. 设计修改用户密码功能时把用户ID保存在哪里?1 1.3. Ui设计1 1.4. 功能设计源码1 1.5. Agt ...

  7. [BTS] BizTalk With EF

    System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' ...

  8. asp.net单点登录(SSO)解决方案

    前些天一位朋友要我帮忙做一单点登录,其实这个概念早已耳熟能详,但实际应用很少,难得最近轻闲,于是决定通过本文来详细描述一个SSO解决方案,希望对大家有所帮助.SSO的解决方案很多,但搜索结果令人大失所 ...

  9. ArcGIS API for Silverlight开发入门

    你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击 ...

  10. 基于.Net的单点登录(SSO)解决方案

    前些天一位朋友要我帮忙做一单点登录,其实这个概念早已耳熟能详,但实际应用很少,难得最近轻闲,于是决定通过本文来详细描述一个SSO解决方案,希望对大家有所帮助.SSO的解决方案很多,但搜索结果令人大失所 ...

随机推荐

  1. 智能化IT运维平台建设方案,基于智和信通运维体系的高敏捷二次开发

    随着企业信息进程不断加速,运维人员需要面对越来越复杂的业务和越来越多样化的用户需求,不断扩展的应用需要越来越合理的模式.越来越智能的工具来保障运维能灵活便捷.安全稳定地开展.企业网络规模的不断扩大,从 ...

  2. android 性能优化 -systrace

    简介: Systrace允许监视和跟踪Android系统的行为(trace).它会指明系统都在哪些工作上花费时间.CPU周期都用在哪里,甚至可以看到每个线程.进程在指定时间内都在干嘛.它同时还会突出观 ...

  3. OpenGL和OpenCL区别

    1.OpenGL用于图形渲染程序:OpenCL用于复杂的计算.他们都是由Khronos管理并使用C语言编译. 2.OpneGL使编程能够进行图形操作:OpenCL使编程能够在多个处理器中进行计算. 3 ...

  4. 墨天轮沙龙 | 北京大学李文杰:面向知识图谱应用的图数据库系统gStore

    在6月8日举办的[墨天轮数据库沙龙第七期-开源生态专场]中,北京大学重庆大数据研究院图数据库与知识图谱实验室副主任.北京大学王选计算机研究所全职博士后 李文杰老师分享了<面向知识图谱应用的图数据 ...

  5. iOS之动画(transform和UIView动画)学习

    1.transform 形变 这个是UIView的属性,继承UIView的控件都具有这个属性 UIImageView *imageview=[[UIImageView alloc]init]; ima ...

  6. dotnet的Lambda表达式 委托泛型(2) Action Func

    // 总结:// 泛型:把类,方法,属性,字段做到了通用化// 反射:操作dll文件的一个帮助类库// 特性:就是一个特殊的类 自定义标记属性特性 他就是AOP的另一种实现方式 验证属性// 委托:就 ...

  7. 全局和局部混入 mixins

    使用 mixins 混入 的目的 :复用代码,维护代码 : 局部混入: 全局混入 + 按钮权限控制 : ps:定义一个方法 ,checkPermission (str) str 是按钮的权限标识 , ...

  8. KubeSphere 对 Apache Log4j 2 远程代码执行最新漏洞的修复方案

    Apache Log4j 2 是一款开源的日志记录工具,被广泛应用于各类框架中.近期,Apache Log4j 2 被爆出存在漏洞,漏洞现已公开,本文为 KubeSphere 用户提供建议的修复方案. ...

  9. KubeSphere 集群配置 NFS 存储解决方案

    作者:申红磊,QingCloud 容器解决方案架构师,开源项目爱好者,KubeSphere Member 在正式阅读本文之前,先友情提醒一下:不建议您在生产环境中使用 NFS 存储(特别是 Kuber ...

  10. OpenPSG:离AGI再进一步,首个开放环境关系预测框架 | ECCV'24

    全景场景图生成(PSG)的目标是对对象进行分割并识别它们之间的关系,从而实现对图像的结构化理解.以往的方法主要集中于预测预定义的对象和关系类别,因此限制了它们在开放世界场景中的应用.随着大型多模态模型 ...