mirror of
https://gitee.com/fujieid/jap.git
synced 2024-11-29 18:17:34 +08:00
✨ bug: Fixed NPE.
This commit is contained in:
parent
38c8dda0a3
commit
320d14fa14
@ -27,6 +27,7 @@ import com.fujieid.jap.core.store.JapUserStore;
|
||||
import com.fujieid.jap.core.strategy.AbstractJapStrategy;
|
||||
import com.fujieid.jap.http.JapHttpRequest;
|
||||
import com.fujieid.jap.http.JapHttpResponse;
|
||||
import com.fujieid.jap.ldap.exception.LdapPasswordException;
|
||||
import com.fujieid.jap.ldap.model.LdapPerson;
|
||||
import com.fujieid.jap.ldap.template.LdapDefaultTemplate;
|
||||
import com.fujieid.jap.ldap.template.LdapTemplate;
|
||||
@ -68,6 +69,9 @@ public class LdapStrategy extends AbstractJapStrategy {
|
||||
String password = request.getParameter(ldapConfig.getPasswordField());
|
||||
LdapTemplate ldapTemplate = new LdapDefaultTemplate(new LdapDataSource(ldapConfig));
|
||||
LdapPerson ldapPerson = ldapTemplate.login(username, password);
|
||||
if (null == ldapPerson) {
|
||||
throw new LdapPasswordException(JapErrorCode.INVALID_PASSWORD);
|
||||
}
|
||||
JapUser japUser = this.japUserService.createAndGetLdapUser(ldapPerson);
|
||||
if (null == japUser) {
|
||||
return JapResponse.error(JapErrorCode.UNABLE_SAVE_USERINFO);
|
||||
|
@ -83,6 +83,9 @@ public class LdapDefaultTemplate implements LdapTemplate {
|
||||
@Override
|
||||
public LdapPerson login(String userName, String password) {
|
||||
LdapPerson ldapPerson = this.findPerson(userName);
|
||||
if (null == ldapPerson) {
|
||||
return null;
|
||||
}
|
||||
LdapPasswordMatch ldapPasswordMatch = LdapPasswordMatchFactory.getMatcherByPassword(ldapPerson.getPassword());
|
||||
if (ldapPasswordMatch.matches(password, ldapPerson.getPassword())) {
|
||||
return ldapPerson;
|
||||
|
Loading…
Reference in New Issue
Block a user