-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Labels
area:docsFeatures or issues related to DocusaurusFeatures or issues related to Docusaurus
Description
Do you see an area that can be clarified or expanded, a technical inaccuracy, or a broken link?
Hi,
The suggested script to Ensure unique email addresses in the documentation seems to have a problem. Indeed, if you add this policy to the default user setting prompt stage, then it prevent users to update their informations (because ak_user_by(email__iexact=email) will match their own account and the policy will return False).
Link
https://docs.goauthentik.io/customize/policies/expression/unique_email/
Solution
The script should then check that the use with this email is different from the current user itself. The following code should do it.
# Ensure this matches the *Field Key* value of the prompt
field_name = "email"
email = request.context["prompt_data"][field_name]
# Search for users with this email
other_user = ak_user_by(email__iexact=email)
if other_user:
# Ensure that it is another user
if ( request.user.username != other_user.username):
ak_message(other_user.username + " already use this email")
return False
return True
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:docsFeatures or issues related to DocusaurusFeatures or issues related to Docusaurus