Unverified Commit 6814a525 authored by hxp0618's avatar hxp0618 Committed by GitHub

[Fix][admin] Repair the problem of login error caused by users not bi… (#1736)

* [Fix][admin] Repair the problem of login error caused by users not binding tenants * [Fix][admin] Repair the problem of login error caused by users not binding tenants * [Fix][admin] Repair the problem of login error caused by users not binding tenants * [Fix][admin] fix code style --------- Co-authored-by: 's avatarhuang <18670141050@163.com>
parent 4f949d87
......@@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
......@@ -68,7 +69,7 @@ public class User implements Serializable {
private Boolean enabled;
private Boolean isDelete;
@TableLogic private Boolean isDelete;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
......
......@@ -128,22 +128,21 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, User> implemen
public Result<UserDTO> loginUser(LoginDTO loginDTO) {
User user = getUserByUsername(loginDTO.getUsername());
if (Asserts.isNull(user)) {
return Result.failed(MessageResolverUtils.getMessage("login.fail"));
return Result.failed(MessageResolverUtils.getMessage("login.user.not.exists"));
}
String userPassword = user.getPassword();
if (Asserts.isNullString(loginDTO.getPassword())) {
return Result.failed(MessageResolverUtils.getMessage("login.password.notnull"));
}
if (Asserts.isEquals(SaSecureUtil.md5(loginDTO.getPassword()), userPassword)) {
if (user.getIsDelete()) {
return Result.failed(MessageResolverUtils.getMessage("login.user.not.exists"));
}
if (!user.getEnabled()) {
return Result.failed(MessageResolverUtils.getMessage("login.user.disabled"));
}
// get user tenants and roles
UserDTO userInfo = refreshUserInfo(user);
if (Asserts.isNullCollection(userInfo.getTenantList())) {
return Result.failed(MessageResolverUtils.getMessage("login.user.not.binding"));
}
StpUtil.login(user.getId(), loginDTO.isAutoLogin());
return Result.succeed(userInfo, MessageResolverUtils.getMessage("login.success"));
} else {
......
......@@ -59,10 +59,6 @@ spring.datasource.druid.stat-view-servlet.login-password=admin
##### mybatis-plus配置
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
mybatis-plus.global-config.db-config.field-strategy=NOT_NULL
#逻辑删除配置
mybatis-plus.global-config.db-config.logic-delete-field=is_delete
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
# 原生配置
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.cache-enabled=false
......@@ -76,4 +72,4 @@ spring.messages.encoding=utf-8
# 表示 messages 文件的缓存失效时间,如果不配置则缓存一直有效。
spring.messages.cache-duration=3600
# 在找不到当前系统对应的资源文件时,如果该属性为 true,则会默认查找当前系统对应的资源文件,否则就返回 null,返回 null 之后,最终又会调用到系统默认的 messages.properties 文件
spring.messages.fallback-to-system-locale=true
\ No newline at end of file
spring.messages.fallback-to-system-locale=true
......@@ -71,6 +71,10 @@ mybatis-plus:
global-config:
db-config:
id-type: auto
#逻辑删除配置
logic-delete-field: is_delete
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
##### mybatis-plus打印完整sql(只适用于开发环境)
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
......
......@@ -55,6 +55,7 @@ login.success=\u767B\u5F55\u6210\u529F
login.password.notnull=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
login.user.not.exists=\u8D26\u53F7\u4E0D\u5B58\u5728
login.user.disabled=\u8D26\u53F7\u5DF2\u88AB\u7981\u7528
login.user.not.binding=\u7528\u6237\u6ca1\u6709\u7ed1\u5b9a\u79df\u6237
outlogin.success=\u9000\u51FA\u6210\u529F
......
......@@ -54,6 +54,7 @@ login.success=Login successful
login.password.notnull=Password cannot be null
login.user.not.exists=Account does not exist
login.user.disabled=Account has been disabled
login.user.not.binding=User is not binding to a tenant
outlogin.success=Exit successfully
......@@ -84,4 +85,4 @@ hdfs.file.lose=If you can't find the core-site.xml/hdfs-site.xml/yarn-site.xml f
unknown.error=Unknown error: {0}
operate.success=operate success
\ No newline at end of file
operate.success=operate success
......@@ -55,6 +55,7 @@ login.success=\u767B\u5F55\u6210\u529F
login.password.notnull=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
login.user.not.exists=\u8D26\u53F7\u4E0D\u5B58\u5728
login.user.disabled=\u8D26\u53F7\u5DF2\u88AB\u7981\u7528
login.user.not.binding=\u7528\u6237\u6ca1\u6709\u7ed1\u5b9a\u79df\u6237
outlogin.success=\u9000\u51FA\u6210\u529F
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment