当前位置:网站首页>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;
}
}
边栏推荐
- Six necessary open source projects for private activities
- 【虹科案例】3D数据如何成为可操作的信息?– 对象检测和跟踪
- Leetcode - linked list written test questions
- Social order in the meta universe
- CPU取指到发出控制、微程序控制原理详细过程
- 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
- UART protocol timing summary
- Basic usage of oushudb database (medium)
- extern、struct等关键字
- C语言:利用自定义函数排序
猜你喜欢

Dependency Inversion Principle

What should I pay attention to in the interview of artificial intelligence technology?

Android 3年外包工面试笔记,有机会还是要去大厂学习提升,作为一个Android程序员

Cloud native architecture (05) - Application Architecture Evolution

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

抖音实战~手机号密码一键注册登录流程(限制手机终端登录)

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

Expander+listbox of WPF effect

2. camera calibration

1. < tag dynamic programming and path combination problem > lt.62 Different paths + lt.63 Different paths II
随机推荐
Android App bundle exploration, client development interview questions
Three Solution to the problem of inaccuracy in radiographic testing under the condition of non full screen canvas of JS
Google Earth Engine(GEE)——NDVI、NDWI和NDBI用来进行增加分类精度的验证结果(随机森林和cart分类)
小猫爪:PMSM之FOC控制15-MRAS法
【面试经验包】面试被吊打经验总结(一)
规律/原理/规则/法则/定理/公理/本质/定律
Go language core 36 lectures (go language practice and application 11) -- learning notes
Android 3年外包工面试笔记,有机会还是要去大厂学习提升,作为一个Android程序员
Expander+listbox of WPF effect
Six necessary open source projects for private activities
Android - JNI 开发你所需要知道的基础,Android工程师面试题
Salesforce batch apex batch processing (V) asyncapexjob intelligence
解决项目依赖报红问题
Easycvr implementation of adding preset point position function of Dahua equipment
What should I pay attention to in the interview of artificial intelligence technology?
Shutter control layout
The easycvr program started abnormally as a service, but the process started normally. What is the reason?
智能制造时代下,MES管理系统需要解决哪些问题
JS language precision problem
[technical grass planting] the tail of the "double 11" event. Let's talk about how much discount the message push service package is!