81 EventBuilder
event = context.getEvent();
82 MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
83 String username = formData.getFirst(
"username");
84 if (username == null || username.isEmpty()) {
85 event.error(Errors.USERNAME_MISSING);
86 Response challenge = context.form()
88 .createPasswordReset();
89 context.failureChallenge(AuthenticationFlowError.INVALID_USER, challenge);
93 username = username.trim();
95 RealmModel realm = context.getRealm();
96 UserModel user = context.getSession().users().getUserByUsername(username, realm);
97 if (user == null && realm.isLoginWithEmailAllowed() && username.contains(
"@")) {
98 user = context.getSession().users().getUserByEmail(username, realm);
107 .detail(Details.USERNAME, username)
108 .error(Errors.USER_NOT_FOUND);
109 }
else if (!user.isEnabled()) {
111 .detail(Details.USERNAME, username)
112 .user(user).error(Errors.USER_DISABLED);
114 context.setUser(user);
Definition: Messages.java:22
static final String MISSING_USERNAME
Definition: Messages.java:49
static final String ATTEMPTED_USERNAME
Definition: AbstractUsernameFormAuthenticator.java:52
Definition: AbstractUsernameFormAuthenticator.java:47