API create user, can't set must_change_password to false. #6555

Closed
opened 2025-11-02 06:59:12 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @insub on GitHub (Dec 20, 2020).

Originally assigned to: @6543 on GitHub.

I set up a gitea service through docker(laster version)
Then signup a admin and get token on web ui.
And use api create a user:

POST /admin/users
 {
    "email": "u1@u.com",
    "full_name": "u1",
    "login_name": "u1",
    "must_change_password": false,
    "password": "123123",
    "send_notify": false,
    "username": "u1"
  }

This user was successfully created,and "must_change_password" parameter is set to false.
But when i use api to create/get this user's tokens (Basic Auth u1/123123):
POST /admin/users/u1/tokens

Then i get 403 error
{"message":"You must change your password. Change it at: http://localhost:3000//user/change_password"}

I goto check SQLite Database, this user's must_change_password attr still is 1.
I try to use api to edit user's must_change_password attr tofalse or 0, But it didn't work. Another attr like "full name" is success. But "must_change_password" still 1.

I'm not sure if this is a bug or if I'm missing some configuration.

Originally created by @insub on GitHub (Dec 20, 2020). Originally assigned to: @6543 on GitHub. I set up a gitea service through docker(laster version) Then signup a admin and get token on web ui. And use api create a user: ``` POST /admin/users { "email": "u1@u.com", "full_name": "u1", "login_name": "u1", "must_change_password": false, "password": "123123", "send_notify": false, "username": "u1" } ``` This user was successfully created,and "must_change_password" parameter is set to false. But when i use api to create/get this user's tokens (Basic Auth u1/123123): `POST /admin/users/u1/tokens` Then i get 403 error `{"message":"You must change your password. Change it at: http://localhost:3000//user/change_password"}` I goto check SQLite Database, this user's must_change_password attr still is 1. I try to use api to edit user's must_change_password attr tofalse or 0, But it didn't work. Another attr like "full name" is success. But "must_change_password" still 1. I'm not sure if this is a bug or if I'm missing some configuration.
GiteaMirror added the type/bugissue/needs-feedbackmodifies/api labels 2025-11-02 06:59:12 -06:00
Author
Owner

@a1012112796 commented on GitHub (Dec 20, 2020):

@insub Hello, I haven't found this bug in master branch, would you please give me which version that you found this bug? Thanks

@a1012112796 commented on GitHub (Dec 20, 2020): @insub Hello, I haven't found this bug in master branch, would you please give me which version that you found this bug? Thanks
Author
Owner

@insub commented on GitHub (Dec 20, 2020):

@a1012112796
I used docker latest version to build the server.

And I checked the version on the web ui (http://192.168.99.100:10080/admin/config) :
1.14.0+dev-324-g173e51270 built with GNU Make 4.3, go1.15.6 : bindata, timetzdata, sqlite, sqlite_unlock_notify

@insub commented on GitHub (Dec 20, 2020): @a1012112796 I used docker latest version to build the server. And I checked the version on the web ui (http://192.168.99.100:10080/admin/config) : 1.14.0+dev-324-g173e51270 built with GNU Make 4.3, go1.15.6 : bindata, timetzdata, sqlite, sqlite_unlock_notify
Author
Owner

@6543 commented on GitHub (Dec 22, 2020):

@insub can not reproduse ...

checked version: 1.14.0+dev-444-gd9699b248

@6543 commented on GitHub (Dec 22, 2020): @insub can not reproduse ... checked version: `1.14.0+dev-444-gd9699b248`
Author
Owner

@insub commented on GitHub (Dec 22, 2020):

@6543 @a1012112796
I found the reason, because i send request's params by "Form", not a JSON object.
I noticed that the example in the api document uses the JSON type, so instead I sent a JSON object parameter, it is ok.

What makes me strange is that using ”Form“ type params can also create users successfully, just the “must_change_password” field cannot be set correctly.

If you guys don't think it is a bug, please close this issue.
Thank you all.

@insub commented on GitHub (Dec 22, 2020): @6543 @a1012112796 I found the reason, because i send request's params by "Form", not a JSON object. I noticed that the example in the api document uses the JSON type, so instead I sent a JSON object parameter, it is ok. What makes me strange is that using ”Form“ type params can also create users successfully, just the “must_change_password” field cannot be set correctly. If you guys don't think it is a bug, please close this issue. Thank you all.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6555