authentik icon indicating copy to clipboard operation
authentik copied to clipboard

Custom Attributes not displayed and saved properly in "Settings"->"User details"

Open eickeh opened this issue 2 years ago • 7 comments

Describe your question/ I'm currently playing around with custom user attributes and they look great! I can type and save something in the custom attributes under "Settings"->"User details" and it's saved to the user attributes and clearly visible in the event log. However, it is not shown there after being saved - the fields are just at their defaults afterwards.

Screenshots

  1. Fill details and save authentik_user_details-filled
  2. User details are empty directly after clicking on save authentik_user_details_empty_again
  3. Event log shows that data was saved authentik_event_log
  4. Data is visible in update user page authentik_update_user

Logs I can provide this if requested.

Version and Deployment (please complete the following information):

  • authentik version: 2024.6.0
  • Deployment: docker-compose

Can anybody help me?

eickeh avatar Jul 10 '24 23:07 eickeh

Nobody? If not, I consider this a bug and change labels

eickeh avatar Jul 22 '24 07:07 eickeh

There is no implied bi-directional binding between prompt fields and user attributes, meaning you need to ensure the data gets loaded too. I recommend looking at the prompt fields from the default user settings flow for username/name/etc

BeryJu avatar Jul 22 '24 11:07 BeryJu

Thanks, that helped! I totally missed that field. Ticking the "Interpret initial value as expression" box and setting initial value e.g. for test_description like that fixed it (the default-user-settings-field-locale even stacks this):

try:
    return user.attributes.get("test_description", "default value")
except:
    return ''

That worked well for radio buttons and text. I didn't get it working for a checkbox or a file. And as those values are not loaded in the settings page, updating the settings without reuploading the file or setting the correct checkbox value causes the file to be deleted from the user attributes and the checkbox value to be set to the default.

I even discovered a bug (report will follow): Entering incorrect python code prevents makes it impossible to edit the prompt - it'll just load forever. (should be fixed by now in https://github.com/goauthentik/authentik/issues/10592)

Any ideas how to fix this?

eickeh avatar Jul 23 '24 11:07 eickeh

Returning a value for a checkbox should be possible, the frontend checks if the initial value is a non-empty string. For file uploads, it's not possible to "load" a value into such an element, so additional logic has to be added in the prompt to not overwrite the attribute with an empty value

BeryJu avatar Sep 26 '24 17:09 BeryJu

Sorry for the probably stupid question, but neither a search on google, reddit nor github helped me find out how you added the custom attributes to the user details form? @eickeh

In my system settings there is no such option :/

Fplusplus avatar Sep 23 '25 09:09 Fplusplus

I think I just took some time to search the UI to find it, not sure if there are docs specifically for this. As far as I understood this, there is not much difference between the forms shown in the user settings and the login forms. You can use both at both places.

To get your field in, go to "Flows and Stages"->"Stages" and edit the "default-user-settings" Stage and add your new field.

eickeh avatar Sep 23 '25 15:09 eickeh

Answered above: prompt fields need an initial value expression such as return user.attributes.get("my_field", "") to show the saved value. The checkbox part is tracked in #27014.

dominic-r avatar Nov 04 '26 04:11 dominic-r