feat: add deletedTime to user (#2652)

This commit is contained in:
Satinder Singh 2024-01-30 07:18:32 -08:00 committed by GitHub
parent 721a681ff1
commit ef373ca736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 20 additions and 1 deletions

View File

@ -93,6 +93,8 @@ func (syncer *Syncer) setUserByKeyValue(user *User, key string, value string) {
user.CreatedTime = value
case "UpdatedTime":
user.UpdatedTime = value
case "DeletedTime":
user.DeletedTime = value
case "Id":
user.Id = value
case "Type":
@ -266,6 +268,7 @@ func (syncer *Syncer) getMapFromOriginalUser(user *OriginalUser) map[string]stri
m["Name"] = user.Name
m["CreatedTime"] = user.CreatedTime
m["UpdatedTime"] = user.UpdatedTime
m["DeletedTime"] = user.DeletedTime
m["Id"] = user.Id
m["Type"] = user.Type
m["Password"] = user.Password

View File

@ -48,6 +48,7 @@ type UserWithoutThirdIdp struct {
Name string `xorm:"varchar(100) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
DeletedTime string `xorm:"varchar(100)" json:"deletedTime"`
Id string `xorm:"varchar(100) index" json:"id"`
Type string `xorm:"varchar(100)" json:"type"`
@ -167,6 +168,7 @@ func getUserWithoutThirdIdp(user *User) *UserWithoutThirdIdp {
Name: user.Name,
CreatedTime: user.CreatedTime,
UpdatedTime: user.UpdatedTime,
DeletedTime: user.DeletedTime,
Id: user.Id,
Type: user.Type,

View File

@ -49,6 +49,7 @@ type User struct {
Name string `xorm:"varchar(100) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
DeletedTime string `xorm:"varchar(100)" json:"deletedTime"`
Id string `xorm:"varchar(100) index" json:"id"`
ExternalId string `xorm:"varchar(100) index" json:"externalId"`
@ -658,6 +659,10 @@ func UpdateUser(id string, user *User, columns []string, isAdmin bool) (bool, er
columns = append(columns, "updated_time")
user.UpdatedTime = util.GetCurrentTime()
if len(user.DeletedTime) > 0 {
columns = append(columns, "deleted_time")
}
if util.ContainsString(columns, "groups") {
_, err := userEnforcer.UpdateGroupsForUser(user.GetId(), user.Groups)
if err != nil {

View File

@ -134,6 +134,7 @@ func UploadUsers(owner string, path string) (bool, error) {
LastSigninIp: parseLineItem(&line, 38),
Ldap: "",
Properties: map[string]string{},
DeletedTime: parseLineItem(&line, 39),
}
if _, ok := oldUserMap[user.GetId()]; !ok {

View File

@ -7446,6 +7446,9 @@
"displayName": {
"type": "string"
},
"deletedTime": {
"type": "string"
},
"douyin": {
"type": "string"
},

View File

@ -4900,6 +4900,8 @@ definitions:
type: string
deezer:
type: string
deletedTime:
type: string
digitalocean:
type: string
dingtalk:

View File

@ -1448,7 +1448,7 @@ export function getFriendlyUserName(account) {
}
export function getUserCommonFields() {
return ["Owner", "Name", "CreatedTime", "UpdatedTime", "Id", "Type", "Password", "PasswordSalt", "DisplayName", "FirstName", "LastName", "Avatar", "PermanentAvatar",
return ["Owner", "Name", "CreatedTime", "UpdatedTime", "DeletedTime", "Id", "Type", "Password", "PasswordSalt", "DisplayName", "FirstName", "LastName", "Avatar", "PermanentAvatar",
"Email", "EmailVerified", "Phone", "Location", "Address", "Affiliation", "Title", "IdCardType", "IdCard", "Homepage", "Bio", "Tag", "Region",
"Language", "Gender", "Birthday", "Education", "Score", "Ranking", "IsDefaultAvatar", "IsOnline", "IsAdmin", "IsForbidden", "IsDeleted", "CreatedIp",
"PreferredMfaType", "TotpSecret", "SignupApplication"];

View File

@ -27,6 +27,7 @@ import * as ApplicationBackend from "./backend/ApplicationBackend";
import PasswordModal from "./common/modal/PasswordModal";
import ResetModal from "./common/modal/ResetModal";
import AffiliationSelect from "./common/select/AffiliationSelect";
import moment from "moment";
import OAuthWidget from "./common/OAuthWidget";
import SamlWidget from "./common/SamlWidget";
import RegionSelect from "./common/select/RegionSelect";
@ -869,6 +870,7 @@ class UserEditPage extends React.Component {
<Col span={(Setting.isMobile()) ? 22 : 2} >
<Switch checked={this.state.user.isDeleted} onChange={checked => {
this.updateUserField("isDeleted", checked);
this.updateUserField("deletedTime", checked ? moment().format() : "");
}} />
</Col>
</Row>

View File

@ -62,6 +62,7 @@ const userTemplate = {
"name": "admin",
"createdTime": "2020-07-16T21:46:52+08:00",
"updatedTime": "",
"deletedTime": "",
"id": "9eb20f79-3bb5-4e74-99ac-39e3b9a171e8",
"type": "normal-user",
"password": "***",