-
Notifications
You must be signed in to change notification settings - Fork 33
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: add user creation endpoint #146
Draft
egabancho
wants to merge
1
commit into
inveniosoftware:master
Choose a base branch
from
ubiquitypress:allow-user-creation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+233
−27
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# Copyright (C) 2022 European Union. | ||
# Copyright (C) 2022 CERN. | ||
# Copyright (C) 2024 KTH Royal Institute of Technology. | ||
# Copyright (C) 2024 Ubiquity Press. | ||
# | ||
# Invenio-Users-Resources is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
|
@@ -115,6 +116,23 @@ def test_user_avatar(client, user_pub): | |
# | ||
# Management / moderation | ||
# | ||
def test_create_user(client, headers, user_moderator, db): | ||
"""Tests approve user endpoint.""" | ||
client = user_moderator.login(client) | ||
res = client.post( | ||
"/users", | ||
json={ | ||
"username": "newuser", | ||
"email": "[email protected]", | ||
}, | ||
headers=headers, | ||
) | ||
assert res.status_code == 201 | ||
|
||
res = client.get(f"/users/{res.json['id']}") | ||
assert res.status_code == 200 | ||
assert res.json["active"] == True | ||
assert res.json["email"] == "[email protected]" | ||
|
||
|
||
def test_approve_user(client, headers, user_pub, user_moderator, db): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
The
_create_user_as_admin
method automatically activates and verifies the user without additional confirmation steps. Should we consider verification steps, such as sending a confirmation email or letting the user log in and self-activate their account as it might be necessary to ensure the user's email is valid and belongs to them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We thought/discussed this internally and concluded that, because an email to change the password has already been sent, the email would be verified and correct once the new user changed their password. Does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's defer to the CERN team on this decision. However, I think it's important to consider that if an admin enters an incorrect email address "admins are still humans :) ", it could result in an active and verified account that isn't linked to the intended user.
Implementing a verification step during the user's first login would ensure that the email is valid and belongs to the correct individual, thereby enhancing account security.