当前位置:网站首页>Empty encoded password warning reason
Empty encoded password warning reason
2022-06-24 00:14:00 【XuDream】
Premise :
- Use SpringSecurity Rights management framework .
- Console prompts during login Empty encoded password.
Possible causes :
- Framework version conflict does not support .
- The database password sub segment is stored in the database without encoding and encryption at the time of registration .
- Incorrect use of entity class .
resolvent :
- Revised version .
- When a new user is added to the database, the foreground password is encoded and stored in the database , The method is below .
- Bear in mind , Login Class and implementation UserDetails The class of cannot be the same , Otherwise, the password will not be found . And inherit UserDetails In the class ,username and password Remember to return to the user in the database username and password.
Register encryption :
@Override
public Res register(LoginBody loginBody) {
String msg = "";
SysUser sysUserDb = baseMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserName, loginBody.getUserName()));
if (sysUserDb != null) {
msg = " Save the user '" + loginBody.getUserName() + "' Failure , The registered account already exists ";
} else {
SysUser sysUser = new SysUser();
sysUser.setUserName(loginBody.getUserName());
sysUser.setNickName(loginBody.getUserName());
sysUser.setPassword(encryptPassword(loginBody.getPassword()));
int regFlag = baseMapper.insert(sysUser);
if (regFlag != 1) {
msg = " Registration failed , Please contact the system administrator ";
}
return Res.ok(" Registered successfully ");
}
return Res.failed(msg);
}
/** * Generate BCryptPasswordEncoder password * * @param password password * @return Encrypted string */
public static String encryptPassword(String password) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.encode(password);
}
Entity class :
Login entity class :
package com.spring.security.entity;
import lombok.Data;
/** * User login object * * @author ruoyi */
@Data
public class LoginBody {
/** * user name */
private String userName;
/** * User password */
private String password;
/** * Verification Code */
private String code;
/** * Unique identification */
private String uuid;
}
Login return entity class :
Be careful getUsername() and getPassword() Method
package com.spring.security.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Set;
/** * @author lenovo * @date 2022/6/20 */
@Data
public class LoginUser implements UserDetails {
/** * The user account */
private String userName;
/** * password * @return */
private String password;
/** * department ID */
private String deptId;
/** * User information */
private SysUser user;
/** * Permission list */
private Set<String> permissions;
/** * User unique identification */
private String token;
/** * Access permissions * @return */
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
/** * Get password * @return */
@Override
public String getPassword() {
return user.getPassword();
}
/** * Get user account * @return */
@Override
public String getUsername() {
return user.getUserName();
}
/** * Whether the account has expired * @return */
@Override
public boolean isAccountNonExpired() {
return true;
}
/** * Is the account locked * @return */
@Override
public boolean isAccountNonLocked() {
return true;
}
/** * Whether the voucher expires * @return */
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/** * Is it enabled? * @return */
@Override
public boolean isEnabled() {
return true;
}
public LoginUser(String deptId, SysUser user, Set<String> permissions)
{
this.deptId = deptId;
this.user = user;
this.permissions = permissions;
}
}
边栏推荐
- C语言:递归实现N的阶乘
- Social order in the meta universe
- 被同事坑到周末加班, 没见过把Redis用成这个鬼样子的。。。
- 合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
- Chaos engineering, learn about it
- What is the difference between concurrency and parallelism?
- Dot and cross product
- Six necessary open source projects for private activities
- Complete collection of development environment configuration -- Visual Studio 2022 installation
- Do280openshift access control -- manage projects and accounts
猜你喜欢

Superscalar processor design yaoyongbin Chapter 3 virtual memory -- Excerpt from subsection 3.1~3.2

What is medical treatment? AI medical concept analysis AI
![[digital signal] spectrum refinement based on MATLAB analog window function [including Matlab source code 1906]](/img/b3/ad289400e9c74f6f1f533a7d560d5c.jpg)
[digital signal] spectrum refinement based on MATLAB analog window function [including Matlab source code 1906]

Chaos engineering, learn about it

UART protocol timing summary

AI技术在医学领域有什么用?

Interview notes for Android outsourcing workers for 3 years. I still need to go to a large factory to learn and improve. As an Android programmer

迷茫的测试/开发程序员,不同人有着不同的故事、有着不同的迷茫......

Quantitative investment model -- research interpretation of high frequency trading market making model (Avellaneda & Stoikov's) & code resources

元宇宙中的社会秩序
随机推荐
【数字信号】基于matlab模拟窗函数频谱细化【含Matlab源码 1906期】
Confused test / development programmers, different people have different stories and different puzzles
SAVE: 软件分析验证和测试平台
Leetcode - linked list written test questions
Android App bundle exploration, client development interview questions
. Net
I was cheated by my colleagues to work overtime on weekends. I haven't seen redis used like this...
Solve the problem of project dependency red reporting
Complete collection of development environment configuration -- Visual Studio 2022 installation
extern、struct等关键字
[technical grass planting] the tail of the "double 11" event. Let's talk about how much discount the message push service package is!
Return, const, volatile keywords
UART protocol timing summary
DO280OpenShift访问控制--管理项目和账户
【第25天】给定一个长度为 n 的数组,统计每个数出现的次数 | 计数哈希
EasyCVR程序以服务启动异常,进程启动却正常,是什么原因?
Dot and cross product
Expander+listbox of WPF effect
Andorid development art exploration notes (2), cross platform applet development framework
Building a digital software factory -- panoramic interpretation of one-stop Devops platform