-
Notifications
You must be signed in to change notification settings - Fork 12
How to intercept a login request?
Ta Van Dung edited this page Jun 18, 2016
·
1 revision
#Answer
To intercept a login request, let's create a LoginRequestHandler class, verify Login information and throw BadRequestException if it's invalid, example:
@Data
@ServerEventHandler(event = ServerEvent.USER_LOGIN)
public class UserLoginHandler {
@RequestParam("1") private String version;
public void handle(AppContext context, String username, String password) throws Exception {
context.command(Log.class).info("user {} login with password = {}, on version = {}",
username, password, version);
if(StringUtils.isEmpty(version))
throw new BadRequestException("Invalid version", 3); // error code = 3
}
}Hello World