Skip to content

Commit

Permalink
auth: modifiy userinfo verification on create/update
Browse files Browse the repository at this point in the history
  • Loading branch information
corgiboygsj committed Mar 22, 2021
1 parent 78f429a commit 250e0b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

import com.baidu.hugegraph.HugeGraph;
Expand Down Expand Up @@ -208,15 +209,15 @@ public HugeUser build() {

@Override
public void checkCreate(boolean isBatch) {
E.checkArgumentNotNull(this.name,
"The name of user can't be null");
E.checkArgumentNotNull(this.password,
"The password of user can't be null");
E.checkArgument(!StringUtils.isEmpty(this.name),
"The name of user can't be null");
E.checkArgument(!StringUtils.isEmpty(this.password),
"The password of user can't be null");
}

@Override
public void checkUpdate() {
E.checkArgument(this.password != null ||
E.checkArgument(!StringUtils.isEmpty(this.password) ||
this.phone != null ||
this.email != null ||
this.avatar != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected User authenticate(ContainerRequestContext context) {

if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
throw new BadRequestException(
"Invalid syntax for username and password");
"Invalid syntax for username and password");
}

// Validate the extracted credentials
Expand Down

0 comments on commit 250e0b8

Please sign in to comment.