-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
User creation API: allow custom "created" timestamps #22549
User creation API: allow custom "created" timestamps #22549
Commits on Jan 20, 2023
-
User creation API: allow custom "created" timestamps
Allow back-dating user creation via the `adminCreateUser` API operation. `CreateUserOption` now has an optional field `created_at`, which can contain a datetime-formatted string. If this field is present, the user's `created_unix` database field will be updated to its value. This is important for Blender's migration of users from Phabricator to Gitea. There are many users, and the creation timestamp of their account can give us some indication as to how long someone's been part of the community. The back-dating is done in a separate query that just updates the user's `created_unix` field. This was the easiest and cleanest way I could find, as in the initial `INSERT` query the field always is set to "now".
Configuration menu - View commit details
-
Copy full SHA for e9858cf - Browse repository at this point
Copy the full SHA e9858cfView commit details -
Regenerate swagger & update field description
Run `make generate-swagger` and update the comment describing the field so that they make sense from an API standpoint (and not just when reading the Go code).
Configuration menu - View commit details
-
Copy full SHA for a7633f3 - Browse repository at this point
Copy the full SHA a7633f3View commit details
Commits on Jan 23, 2023
-
Thanks @yardenshoham for spotting this. Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Configuration menu - View commit details
-
Copy full SHA for 036b16d - Browse repository at this point
Copy the full SHA 036b16dView commit details -
Update comments, avoid mentioning back-dating.
Since any timestamp is accepted by the system, avoid mentioning "back-dating" user creation.
Configuration menu - View commit details
-
Copy full SHA for 4831ec6 - Browse repository at this point
Copy the full SHA 4831ec6View commit details -
Configuration menu - View commit details
-
Copy full SHA for ce97999 - Browse repository at this point
Copy the full SHA ce97999View commit details -
Use
NoAutoTime()
to allow manual changes to creation timestampWith this change to the "insert" query, it was possible to set the creation timestamp: ```diff @@ -740,11 +747,11 @@ func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err e if err = DeleteUserRedirect(ctx, u.Name); err != nil { return err } - if err = db.Insert(ctx, u); err != nil { + if _, err = db.GetEngine(ctx).NoAutoTime().Insert(u); err != nil { return err } // insert email address if err := db.Insert(ctx, &EmailAddress{ ```
Configuration menu - View commit details
-
Copy full SHA for 256dcf5 - Browse repository at this point
Copy the full SHA 256dcf5View commit details -
Configuration menu - View commit details
-
Copy full SHA for fcc33fe - Browse repository at this point
Copy the full SHA fcc33feView commit details
Commits on Jan 24, 2023
-
Detect whether
NoAutoTime()
should be used + a unittestDetect whether `NoAutoTime()` should be used based on `u.CreatedUnix`, and add two unittests that test the new functionality.
Configuration menu - View commit details
-
Copy full SHA for 7e0b525 - Browse repository at this point
Copy the full SHA 7e0b525View commit details -
Configuration menu - View commit details
-
Copy full SHA for e48c075 - Browse repository at this point
Copy the full SHA e48c075View commit details
Commits on Jan 27, 2023
-
Suggestion by @wolfogre Co-authored-by: Jason Song <i@wolfogre.com>
Configuration menu - View commit details
-
Copy full SHA for 6fd9f18 - Browse repository at this point
Copy the full SHA 6fd9f18View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5d22df3 - Browse repository at this point
Copy the full SHA 5d22df3View commit details
Commits on Feb 10, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 205d0f1 - Browse repository at this point
Copy the full SHA 205d0f1View commit details
Commits on Feb 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for f2bd162 - Browse repository at this point
Copy the full SHA f2bd162View commit details -
Configuration menu - View commit details
-
Copy full SHA for 931744f - Browse repository at this point
Copy the full SHA 931744fView commit details
Commits on Feb 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9354d5c - Browse repository at this point
Copy the full SHA 9354d5cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 25b6aef - Browse repository at this point
Copy the full SHA 25b6aefView commit details
Commits on Feb 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 3732233 - Browse repository at this point
Copy the full SHA 3732233View commit details