Skip to content
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

users: create user record on registration #235

Merged
merged 1 commit into from
Jun 18, 2020
Merged

users: create user record on registration #235

merged 1 commit into from
Jun 18, 2020

Conversation

sebdeleze
Copy link
Contributor

@sebdeleze sebdeleze commented Jun 3, 2020

  • Creates a user record when a new account is registered.
  • Disables invenio-userprofiles module.
  • Exposes and uses user record for displaying user information in templates.
  • Gives role user by default when a new record is created.
  • Removes organisation from required fields for users.
  • Hides applications and security menu entries.
  • Creates a new page for editing user data.
  • Removes useless CSS rules
  • Adds CSS rules for standalone editor.
  • Customizes settings page.

Co-Authored-by: Sébastien Délèze [email protected]

How to test

Standard registration form

  1. Register as new user with standard registration form.
  2. Login as superuser.
  3. Check a user record is created with same email and roles as user account.

Switch edu-ID

  1. Login with Switch edu-ID account to create a new account.
  2. Login as superuser.
  3. Check a user record is created with same email and roles as user account.

ORCID

  1. Login with ORCID account to create a new account.
  2. Login as superuser.
  3. Check a user record is created with same email and roles as user account.

@sebdeleze sebdeleze marked this pull request as ready for review June 3, 2020 14:05
@sebdeleze sebdeleze requested review from zannkukai and jma and removed request for zannkukai June 17, 2020 13:29
sonar/modules/ext.py Show resolved Hide resolved
@@ -67,9 +67,15 @@ def import_users(infile):
password = hash_password(password)
del user_data['password']

if not user_data.get('roles'):
user_data['roles'] = [UserRecord.ROLE_USER]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not having the roles in the fixtures file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally it's the case, it's just to insure that the user as at least the role "user".

roles = []

for role in roles:
if not datastore.find_role(role):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this take while it can be afterward with a unique list of collected roles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure, because we need the roles to create user account just after. But maybe yes, we can collect all roles before and create them before creating users.

:param user: User account.
"""
# Add a default role to user
role = datastore.find_role(UserRecord.ROLE_USER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not doing this in the UserRecord class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related to UserRecord, but to Flask account created, which has no role.

* Creates a user record when a new account is registered.
* Disables `invenio-userprofiles` module.
* Exposes and uses user record for displaying user information in templates.
* Gives role `user` by default when a new record is created.
* Removes `organisation` from required fields for users.
* Hides `applications` and `security` menu entries.
* Creates a new page for editing user data.
* Removes useless CSS rules
* Adds CSS rules for standalone editor.
* Customizes settings page.

Co-Authored-by: Sébastien Délèze <[email protected]>
@sebdeleze sebdeleze merged commit 804ca2f into rero:dev Jun 18, 2020
@sebdeleze sebdeleze deleted the sed-sync-account-on-registration branch June 18, 2020 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants