New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing terms_accepted in user attributes #43
Comments
Same here. (with KeyCloak 16.1.1) |
The code is wrong. In the success function keycloak has already inserted data into database. If you add attribute to userModel there that attribute will never be saved into database. I have changed the approch, i removed the success function and changed the validate function like: public void validate(ValidationContext context) {
MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
// Now i use a radio instead of checkbox
String termsAccepted = formData.getFirst(TERMS_FIELD);
if (! termsAccepted.equals("1")) {
context.error(Errors.INVALID_REGISTRATION);
formData.remove(TERMS_FIELD);
List<FormMessage> errors = List.of(new FormMessage(TERMS_FIELD, TERMS_REQUIRED_MESSAGE));
context.validationError(formData, errors);
return;
} else {
String termsTimestamp = String.valueOf(System.currentTimeMillis());
formData.add(TERMS_ACCEPTED_ATTRIBUTE, termsTimestamp);
}
super.validate(context);
} |
Thank you for sharing! |
Hmm... are you sure |
Okay, my mistake. I've forgot to add the |
Thanks for sharing! |
Hi! Two things I learned here:
|
Thanks for taking the time to get back to me.
|
This is the full code that is working for us:
|
Step to reproduce
SPI Correctly builded, deployed.
Registration flow configured and registration.ftl changed following the README.md
I register a new user.
If I check the "Attributes" tab in the user detail I can't find the attribute terms_accepted.
This code runs without errors.
Other debug info
I have added two debug row
before and after the row
This way:
I obtain in my log:
terms_accepted is present!
But in the admin area:
term_accepted is missing
In the DB terms_accepted is missing...
What's is wrong?
The text was updated successfully, but these errors were encountered: