pallets-eco / flask-security-3.0

Quick and simple security for Flask applications
MIT License
1.63k stars 512 forks source link

Suggest creating alias for `unique_user_email` field validator #481

Open hc-12 opened 8 years ago

hc-12 commented 8 years ago

With the introduction of SECURITY_USER_IDENTITY_ATTRIBUTES we can easily add identity attributes (which has not yet been documented).

I can set this in my config: SECURITY_USER_IDENTITY_ATTRIBUTES = ['email', 'username']

With custom form:

from flask_security.forms import RegisterForm, unique_user_email

# an alias to reflect a more accurate usage of the validator
unique_user_attribute = unique_user_email

class ExtendedRegisterForm(RegisterForm):
    username = StringField('Username', [validators.Required(), unique_user_attribute])

tl;dr unique_user_email validator is not quite accurate name with the introduction of SECURITY_USER_IDENTITY_ATTRIBUTES

jirikuncar commented 7 years ago

@hc-12 unique_user_attribute sounds good. Feel free to submit a PR.