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
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
|
|
|
@ -63,7 +63,7 @@ public class UserServiceImpl implements UserService {
|
|||
@Override
|
||||
public User findUser() {
|
||||
List<User> users = userRepository.findAll();
|
||||
if(users.size()>0){
|
||||
if (users != null && users.size() > 0) {
|
||||
return users.get(0);
|
||||
} else {
|
||||
return new User();
|
||||
|
@ -115,7 +115,7 @@ public class UserServiceImpl implements UserService {
|
|||
@Override
|
||||
public Integer updateUserLoginError() {
|
||||
User user = this.findUser();
|
||||
user.setLoginError(user.getLoginError()+1);
|
||||
user.setLoginError((user.getLoginError() == null ? 0 : user.getLoginError()) + 1);
|
||||
userRepository.save(user);
|
||||
return user.getLoginError();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue