mirror of https://github.com/halo-dev/halo
fix bug: NullPointerException occurred when failed to login
parent
2432b7cc24
commit
764b86e4ad
|
@ -9,6 +9,7 @@ logs/
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
.springBeans
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea
|
.idea
|
||||||
|
@ -27,4 +28,4 @@ nbdist/
|
||||||
|
|
||||||
### Mac
|
### Mac
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*/.DS_Store
|
*/.DS_Store
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class UserServiceImpl implements UserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<User> userLoginByName(String userName, String userPass) {
|
public List<User> userLoginByName(String userName, String userPass) {
|
||||||
return userRepository.findByUserNameAndUserPass(userName,userPass);
|
return userRepository.findByUserNameAndUserPass(userName, userPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public class UserServiceImpl implements UserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<User> userLoginByEmail(String userEmail, String userPass) {
|
public List<User> userLoginByEmail(String userEmail, String userPass) {
|
||||||
return userRepository.findByUserEmailAndUserPass(userEmail,userPass);
|
return userRepository.findByUserEmailAndUserPass(userEmail, userPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +63,9 @@ public class UserServiceImpl implements UserService {
|
||||||
@Override
|
@Override
|
||||||
public User findUser() {
|
public User findUser() {
|
||||||
List<User> users = userRepository.findAll();
|
List<User> users = userRepository.findAll();
|
||||||
if(users.size()>0){
|
if (users != null && users.size() > 0) {
|
||||||
return users.get(0);
|
return users.get(0);
|
||||||
}else{
|
} else {
|
||||||
return new User();
|
return new User();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class UserServiceImpl implements UserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public User findByUserIdAndUserPass(Long userId, String userPass) {
|
public User findByUserIdAndUserPass(Long userId, String userPass) {
|
||||||
return userRepository.findByUserIdAndUserPass(userId,userPass);
|
return userRepository.findByUserIdAndUserPass(userId, userPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +115,7 @@ public class UserServiceImpl implements UserService {
|
||||||
@Override
|
@Override
|
||||||
public Integer updateUserLoginError() {
|
public Integer updateUserLoginError() {
|
||||||
User user = this.findUser();
|
User user = this.findUser();
|
||||||
user.setLoginError(user.getLoginError()+1);
|
user.setLoginError((user.getLoginError() == null ? 0 : user.getLoginError()) + 1);
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
return user.getLoginError();
|
return user.getLoginError();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue