You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
## 一、源码说明
|
|
|
|
|
登陆功能接口:/api/account/auth/form
|
|
|
|
|
由 AccountController 控制器的 authGetToken 方法处理
|
|
|
|
|
![[Pasted image 20250527155030.png]]
|
|
|
|
|
|
|
|
|
|
实现代码如下:
|
|
|
|
|
![[Pasted image 20250527155131.png]]
|
|
|
|
|
|
|
|
|
|
处理逻辑:
|
|
|
|
|
1. 校验账号,用 sureness.yml 中配置的默认账号进行校验
|
|
|
|
|
2. 校验密码
|
|
|
|
|
3. 获取角色并生成 token 返回
|
|
|
|
|
|
|
|
|
|
*需要熟悉 Sureness 框架
|
|
|
|
|
|
|
|
|
|
## 二、改造方案
|
|
|
|
|
|
|
|
|
|
*重写过滤器并覆盖原有的 Sureness 过滤器
|
|
|
|
|
|
|
|
|
|
1. 新增过滤器
|
|
|
|
|
![[Pasted image 20250530162217.png]]
|
|
|
|
|
|
|
|
|
|
2. 新增sureness 配置
|
|
|
|
|
![[Pasted image 20250530162359.png]]
|
|
|
|
|
由于原项目引入了自动配置,这里必须注释,不然会有默认的过滤器
|
|
|
|
|
![[Pasted image 20250530162340.png]]
|
|
|
|
|
再单独引入sureness
|
|
|
|
|
![[Pasted image 20250530162528.png]]
|