Changeset 1d92bf2 in OpenWorkouts-current for ow/schemas/user.py


Ignore:
Timestamp:
Dec 16, 2018, 1:07:04 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
6560b8f
Parents:
929097a
Message:

(#37) Allow login using email address instead of username:

  • Use user uids as keys in the root folder for referencing user objects (instead of username)
  • Use uids for referencing users all over the place (auth, permissions, traversal urls, etc)
  • Replaced the username concept with nickname. This nickname will be used as a shortcut to access "public profile" pages for users
  • Reworked lots of basic methods in the OpenWorkouts root object (s/username/nickname, marked as properties some methods like users, emails, etc)
  • Added new add_user() and delete_user() helpers to the OpenWorkouts root object
  • Fixed bug in the dashboard redirect view, causing an endless loop if an authenticated user does not exist anymore when loading a page.
  • Lots of tests fixes, adaptations and catch up.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/schemas/user.py

    r929097a r1d92bf2  
    1919
    2020
    21 class UniqueUsername(validators.UnicodeString):
     21class UniqueNickname(validators.UnicodeString):
    2222    messages = {
    23         "name_exists": _('Another user is already registered with the '
    24                          'username %(name)s')
     23        "name_exists": _('Another user is already using the nickname %(name)s')
    2524    }
    2625
    2726    def _validate_python(self, value, state):
    28         super(UniqueUsername, self)._validate_python(value, state)
     27        super(UniqueNickname, self)._validate_python(value, state)
    2928        if value.lower() in state.names:
    3029            raise validators.Invalid(
     
    5150    allow_extra_fields = True
    5251    filter_extra_fields = True
    53     uid = validators.UnicodeString()
     52    email = UniqueEmail(not_empty=True)
     53    nickname = UniqueNickname(if_missing='')
    5454    firstname = validators.UnicodeString()
    5555    lastname = validators.UnicodeString()
    56     email = validators.Email(not_empty=True)
    5756    group = validators.UnicodeString(if_missing='')
    5857
     
    9291    allow_extra_fields = True
    9392    filter_extra_fields = True
    94     username = UniqueUsername(not_empty=True)
     93    nickname = UniqueNickname()
    9594    firstname = validators.UnicodeString(not_empty=True)
    9695    lastname = validators.UnicodeString(not_empty=True)
     
    108107    allow_extra_fields = True
    109108    filter_extra_fields = True
    110     username = UniqueUsername(not_empty=True)
     109    nickname = UniqueNickname()
    111110    email = UniqueEmail(not_empty=True)
Note: See TracChangeset for help on using the changeset viewer.