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

On user creation, status is always 1 even if set to another value #143

Closed
marc-farre opened this issue Oct 31, 2023 · 3 comments
Closed
Assignees

Comments

@marc-farre
Copy link
Contributor

marc-farre commented Oct 31, 2023

Steps to reproduce:

Create a new user using https://marketplace.humhub.com/module/rest/docs/html/user.html#tag/User/paths/~1user/post

In the POST data, set the status to 2:

"account": {
"username": "john.doe",
"email": "[email protected]",
"status": 2,
"tagsField": [],
"language": "DE",
"authclient": "local",
"authclient_id": "0123456789"
},

The new user has status 1.

This is because no scenario is defined on the User model before loading data.
And with no scenario, the status property is no returned User::safeAttributes().

So we need to set the scenario to User::SCENARIO_EDIT_ADMIN.

Problem: authclient and authclient_id are still not safe attributes with User::SCENARIO_EDIT_ADMIN.

Solution 1: in User::scenarios(), add 'authclient', 'authclient_id' to $scenarios[self::SCENARIO_EDIT_ADMIN]

Solution 2: create a new one such as User::SCENARIO_REST_API_EDIT_ADMIN.
And in User::scenarios() we could add:

$scenarios[self::SCENARIO_REST_API_EDIT_ADMIN] = ['username', 'email', 'status', 'visibility', 'language', 'tagsField', 'authclient', 'authclient_id'];`
@marc-farre
Copy link
Contributor Author

@luke- #144 fixes the problem for the status property.

For authclient and authclient_id, see above (I did no test for my proposal).

@yurabakhtin
Copy link
Contributor

@luke- This PR is related to the #140 which was done only for update action, so yes we need the same fix for create action as well.

@luke- luke- closed this as completed in bedc0d9 Nov 3, 2023
luke- added a commit that referenced this issue Nov 3, 2023
…us-is-always-1

Fix #143: On user creation, status is always 1 even if set to another value
@luke-
Copy link
Contributor

luke- commented Nov 3, 2023

@marc-farre @yurabakhtin Thanks!

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

No branches or pull requests

3 participants