当前位置:网站首页>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;
}
}
边栏推荐
- Quantitative investment model -- research interpretation of high frequency trading market making model (Avellaneda & Stoikov's) & code resources
- 2021-11-23: Regulations: l[1] corresponds to a, l[2] corresponds to B, l[3] corresponds to C
- Nlp-d58-nlp competition d27 & question brushing D14 & Paper Reading & MathType
- Learn PWN from CTF wiki - ret2text
- Jeecgboot old version 2 x 3. X how to integrate building block reports?
- 【面试经验包】面试被吊打经验总结(一)
- Three Solution to the problem of inaccuracy in radiographic testing under the condition of non full screen canvas of JS
- 利用Scanorama高效整合异质单细胞转录组
- Go language core 36 lectures (go language practice and application 11) -- learning notes
- Summary of common register bit operation modes in MCU
猜你喜欢

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

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

Save: software analysis, verification and test platform

Tiktok practice ~ password retrieval

What is the use of AI technology in the medical field?

extern、struct等关键字

CPU取指到发出控制、微程序控制原理详细过程

Dependency Inversion Principle

Windows10 security mode entry cycle blue screen repair

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
随机推荐
Basic usage of oushudb database (medium)
Tiktok practice ~ one click registration and login process of mobile phone number and password (restrict mobile terminal login)
Superscalar processor design yaoyongbin Chapter 3 virtual memory -- Excerpt from subsection 3.1~3.2
What is the use of AI technology in the medical field?
元宇宙中的社会秩序
Jeecgboot old version 2 x 3. X how to integrate building block reports?
Andorid development art exploration notes (2), cross platform applet development framework
How to get started with machine learning?
Accompanist组件库中文指南 - Glide篇,劲爆
云原生架构(05)-应用架构演进
医疗是什么?AI医疗概念解析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
985本3Android程序员40天拿下阿里P6口头offer,面试成功后整理了这些面试思路
利用Scanorama高效整合异质单细胞转录组
[leetcode notes] no118 Yanghui triangle
Another short video app with high imitation and eye opening
合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
毕业设计-论文写作笔记【毕设题目类型、论文写作细节、毕设资料】
SQL数据库:知识点汇总,期末不挂科
[technical grass planting] the tail of the "double 11" event. Let's talk about how much discount the message push service package is!