diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/secutiry/AuthorizationController.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/secutiry/AuthorizationController.java index 321bfa3..068e55b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/secutiry/AuthorizationController.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/secutiry/AuthorizationController.java @@ -3,18 +3,13 @@ package org.nl.system.controller.secutiry; import cn.dev33.satoken.stp.StpUtil; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; -import com.wf.captcha.base.Captcha; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.nl.common.utils.RedisUtils; import org.nl.common.utils.SecurityUtils; import org.nl.common.utils.dto.CurrentUser; -import org.nl.common.security.config.bean.LoginCodeEnum; -import org.nl.common.security.config.bean.LoginProperties; import org.nl.system.service.secutiry.impl.OnlineUserService; import org.nl.system.service.user.ISysUserService; import org.nl.system.service.user.dao.SysUser; @@ -24,9 +19,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; import java.util.Map; -import java.util.concurrent.TimeUnit; /** * @author Zheng Jie @@ -38,14 +31,10 @@ import java.util.concurrent.TimeUnit; @RequestMapping("/auth") @Api(tags = "系统:系统授权接口") public class AuthorizationController { - @Autowired - private RedisUtils redisUtils; @Autowired private OnlineUserService onlineUserService; @Autowired private ISysUserService userService; - @Autowired - private LoginProperties loginProperties; @ApiOperation("登录授权") @PostMapping(value = "/login") @@ -77,27 +66,6 @@ public class AuthorizationController { return ResponseEntity.noContent().build(); } - @ApiOperation("获取验证码") - @GetMapping(value = "/code") - public ResponseEntity getCode() { - // 获取运算的结果 - Captcha captcha = loginProperties.getCaptcha(); - String uuid = IdUtil.simpleUUID(); - //当验证码类型为 arithmetic时且长度 >= 2 时,captcha.text()的结果有几率为浮点型 - String captchaValue = captcha.text(); - if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() && captchaValue.contains(".")) { - captchaValue = captchaValue.split("\\.")[0]; - } - // 保存 - redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES); - // 验证码信息 - Map imgResult = new HashMap(2) {{ - put("img", captcha.toBase64()); - put("uuid", uuid); - }}; - return ResponseEntity.ok(imgResult); - } - @ApiOperation("退出登录") @DeleteMapping(value = "/logout") public ResponseEntity logout(HttpServletRequest request) { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java index b63ef55..96f74eb 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/secutiry/impl/OnlineUserService.java @@ -215,16 +215,6 @@ public class OnlineUserService { // 密码解密 - 前端的加密规则: encrypt AuthUserDto authUser = JSON.toJavaObject((JSON) JSON.toJSON(paramMap), AuthUserDto.class); String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword()); - // 查询验证码 - String code = (String) redisUtils.get(authUser.getUuid()); - // 清除验证码 - redisUtils.del(authUser.getUuid()); - if (StrUtil.isEmpty(code)) { - throw new BadRequestException("验证码不存在或已过期"); - } - if (StrUtil.isEmpty(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) { - throw new BadRequestException("验证码错误"); - } // 校验数据库 // 根据用户名查询,在比对密码 SysUser userInfo = sysUserService.getOne(new QueryWrapper().eq("username",authUser.getUsername())); diff --git a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml index 25c74a4..090051c 100644 --- a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml @@ -81,24 +81,8 @@ spring: login: # 登录缓存 cache-enable: true - # 是否限制单用户登录 + # 是否限制单用户登录 single-login: false - # 验证码 - login-code: - # 验证码类型配置 查看 LoginProperties 类 - code-type: arithmetic - # 登录图形验证码有效时间/分钟 - expiration: 2 - # 验证码高度 - width: 111 - # 验证码宽度 - heigth: 36 - # 内容长度 - length: 2 - # 字体名称,为空则使用默认字体 - font-name: - # 字体大小 - font-size: 25 #是否允许生成代码,生产环境设置为false generator: @@ -135,8 +119,8 @@ logging: sa-token: # token 名称 (同时也是cookie名称) token-name: Authorization - # token 有效期,单位s 默认30天, -1代表永不过期 - timeout: 2592000 + # token 有效期,单位s 默认24小时, -1代表永不过期 + timeout: 86400 # token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 activity-timeout: -1 # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) diff --git a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-prod.yml b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-prod.yml index e247274..9a2c2d4 100644 --- a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-prod.yml +++ b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-prod.yml @@ -81,24 +81,8 @@ spring: login: # 登录缓存 cache-enable: true - # 是否限制单用户登录 + # 是否限制单用户登录 single-login: false - # 验证码 - login-code: - # 验证码类型配置 查看 LoginProperties 类 - code-type: arithmetic - # 登录图形验证码有效时间/分钟 - expiration: 2 - # 验证码高度 - width: 111 - # 验证码宽度 - heigth: 36 - # 内容长度 - length: 2 - # 字体名称,为空则使用默认字体 - font-name: - # 字体大小 - font-size: 25 #是否允许生成代码,生产环境设置为false generator: @@ -135,8 +119,8 @@ logging: sa-token: # token 名称 (同时也是cookie名称) token-name: Authorization - # token 有效期,单位s 默认30天, -1代表永不过期 - timeout: 2592000 + # token 有效期,单位s 默认24小时, -1代表永不过期 + timeout: 86400 # token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 activity-timeout: -1 # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) diff --git a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-test.yml b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-test.yml index 4819ab1..b1444fc 100644 --- a/acs/nladmin-system/nlsso-server/src/main/resources/config/application-test.yml +++ b/acs/nladmin-system/nlsso-server/src/main/resources/config/application-test.yml @@ -72,24 +72,8 @@ spring: login: # 登录缓存 cache-enable: true - # 是否限制单用户登录 + # 是否限制单用户登录 single-login: false - # 验证码 - login-code: - # 验证码类型配置 查看 LoginProperties 类 - code-type: arithmetic - # 登录图形验证码有效时间/分钟 - expiration: 2 - # 验证码高度 - width: 111 - # 验证码宽度 - heigth: 36 - # 内容长度 - length: 2 - # 字体名称,为空则使用默认字体,如遇到线上乱码,设置其他字体即可 - font-name: - # 字体大小 - font-size: 25 #jwt jwt: @@ -151,8 +135,8 @@ logging: sa-token: # token 名称 (同时也是cookie名称) token-name: Authorization - # token 有效期,单位s 默认30天, -1代表永不过期 - timeout: 2592000 + # token 有效期,单位s 默认24小时, -1代表永不过期 + timeout: 86400 # token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 activity-timeout: -1 # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) diff --git a/acs/nladmin-ui/src/api/login.js b/acs/nladmin-ui/src/api/login.js index fe257d2..df85b48 100644 --- a/acs/nladmin-ui/src/api/login.js +++ b/acs/nladmin-ui/src/api/login.js @@ -1,14 +1,12 @@ import request from '@/utils/request' -export function login(username, password, code, uuid) { +export function login(username, password) { return request({ url: 'auth/login', method: 'post', data: { username, - password, - code, - uuid + password } }) } @@ -20,13 +18,6 @@ export function getInfo() { }) } -export function getCodeImg() { - return request({ - url: 'auth/code', - method: 'get' - }) -} - export function logout() { return request({ url: 'auth/logout', diff --git a/acs/nladmin-ui/src/store/modules/user.js b/acs/nladmin-ui/src/store/modules/user.js index cf272e8..5ee03da 100644 --- a/acs/nladmin-ui/src/store/modules/user.js +++ b/acs/nladmin-ui/src/store/modules/user.js @@ -30,7 +30,7 @@ const user = { Login({ commit }, userInfo) { // const rememberMe = userInfo.rememberMe return new Promise((resolve, reject) => { - login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid).then(res => { + login(userInfo.username, userInfo.password).then(res => { // setToken(res.token, rememberMe) commit('SET_TOKEN', res.token) setUserInfo(res.user, commit) diff --git a/acs/nladmin-ui/src/views/login.vue b/acs/nladmin-ui/src/views/login.vue index 5db6659..164a225 100644 --- a/acs/nladmin-ui/src/views/login.vue +++ b/acs/nladmin-ui/src/views/login.vue @@ -13,14 +13,6 @@ - - - - - - 记住我 @@ -43,7 +35,6 @@