mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
feat: add deletedTime to user (#2652)
This commit is contained in:
parent
721a681ff1
commit
ef373ca736
@ -93,6 +93,8 @@ func (syncer *Syncer) setUserByKeyValue(user *User, key string, value string) {
|
|||||||
user.CreatedTime = value
|
user.CreatedTime = value
|
||||||
case "UpdatedTime":
|
case "UpdatedTime":
|
||||||
user.UpdatedTime = value
|
user.UpdatedTime = value
|
||||||
|
case "DeletedTime":
|
||||||
|
user.DeletedTime = value
|
||||||
case "Id":
|
case "Id":
|
||||||
user.Id = value
|
user.Id = value
|
||||||
case "Type":
|
case "Type":
|
||||||
@ -266,6 +268,7 @@ func (syncer *Syncer) getMapFromOriginalUser(user *OriginalUser) map[string]stri
|
|||||||
m["Name"] = user.Name
|
m["Name"] = user.Name
|
||||||
m["CreatedTime"] = user.CreatedTime
|
m["CreatedTime"] = user.CreatedTime
|
||||||
m["UpdatedTime"] = user.UpdatedTime
|
m["UpdatedTime"] = user.UpdatedTime
|
||||||
|
m["DeletedTime"] = user.DeletedTime
|
||||||
m["Id"] = user.Id
|
m["Id"] = user.Id
|
||||||
m["Type"] = user.Type
|
m["Type"] = user.Type
|
||||||
m["Password"] = user.Password
|
m["Password"] = user.Password
|
||||||
|
@ -48,6 +48,7 @@ type UserWithoutThirdIdp struct {
|
|||||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||||
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
|
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
|
||||||
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
|
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
|
||||||
|
DeletedTime string `xorm:"varchar(100)" json:"deletedTime"`
|
||||||
|
|
||||||
Id string `xorm:"varchar(100) index" json:"id"`
|
Id string `xorm:"varchar(100) index" json:"id"`
|
||||||
Type string `xorm:"varchar(100)" json:"type"`
|
Type string `xorm:"varchar(100)" json:"type"`
|
||||||
@ -167,6 +168,7 @@ func getUserWithoutThirdIdp(user *User) *UserWithoutThirdIdp {
|
|||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
CreatedTime: user.CreatedTime,
|
CreatedTime: user.CreatedTime,
|
||||||
UpdatedTime: user.UpdatedTime,
|
UpdatedTime: user.UpdatedTime,
|
||||||
|
DeletedTime: user.DeletedTime,
|
||||||
|
|
||||||
Id: user.Id,
|
Id: user.Id,
|
||||||
Type: user.Type,
|
Type: user.Type,
|
||||||
|
@ -49,6 +49,7 @@ type User struct {
|
|||||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||||
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
|
CreatedTime string `xorm:"varchar(100) index" json:"createdTime"`
|
||||||
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
|
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
|
||||||
|
DeletedTime string `xorm:"varchar(100)" json:"deletedTime"`
|
||||||
|
|
||||||
Id string `xorm:"varchar(100) index" json:"id"`
|
Id string `xorm:"varchar(100) index" json:"id"`
|
||||||
ExternalId string `xorm:"varchar(100) index" json:"externalId"`
|
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")
|
columns = append(columns, "updated_time")
|
||||||
user.UpdatedTime = util.GetCurrentTime()
|
user.UpdatedTime = util.GetCurrentTime()
|
||||||
|
|
||||||
|
if len(user.DeletedTime) > 0 {
|
||||||
|
columns = append(columns, "deleted_time")
|
||||||
|
}
|
||||||
|
|
||||||
if util.ContainsString(columns, "groups") {
|
if util.ContainsString(columns, "groups") {
|
||||||
_, err := userEnforcer.UpdateGroupsForUser(user.GetId(), user.Groups)
|
_, err := userEnforcer.UpdateGroupsForUser(user.GetId(), user.Groups)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -134,6 +134,7 @@ func UploadUsers(owner string, path string) (bool, error) {
|
|||||||
LastSigninIp: parseLineItem(&line, 38),
|
LastSigninIp: parseLineItem(&line, 38),
|
||||||
Ldap: "",
|
Ldap: "",
|
||||||
Properties: map[string]string{},
|
Properties: map[string]string{},
|
||||||
|
DeletedTime: parseLineItem(&line, 39),
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := oldUserMap[user.GetId()]; !ok {
|
if _, ok := oldUserMap[user.GetId()]; !ok {
|
||||||
|
@ -7446,6 +7446,9 @@
|
|||||||
"displayName": {
|
"displayName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"deletedTime": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"douyin": {
|
"douyin": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -4900,6 +4900,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
deezer:
|
deezer:
|
||||||
type: string
|
type: string
|
||||||
|
deletedTime:
|
||||||
|
type: string
|
||||||
digitalocean:
|
digitalocean:
|
||||||
type: string
|
type: string
|
||||||
dingtalk:
|
dingtalk:
|
||||||
|
@ -1448,7 +1448,7 @@ export function getFriendlyUserName(account) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getUserCommonFields() {
|
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",
|
"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",
|
"Language", "Gender", "Birthday", "Education", "Score", "Ranking", "IsDefaultAvatar", "IsOnline", "IsAdmin", "IsForbidden", "IsDeleted", "CreatedIp",
|
||||||
"PreferredMfaType", "TotpSecret", "SignupApplication"];
|
"PreferredMfaType", "TotpSecret", "SignupApplication"];
|
||||||
|
@ -27,6 +27,7 @@ import * as ApplicationBackend from "./backend/ApplicationBackend";
|
|||||||
import PasswordModal from "./common/modal/PasswordModal";
|
import PasswordModal from "./common/modal/PasswordModal";
|
||||||
import ResetModal from "./common/modal/ResetModal";
|
import ResetModal from "./common/modal/ResetModal";
|
||||||
import AffiliationSelect from "./common/select/AffiliationSelect";
|
import AffiliationSelect from "./common/select/AffiliationSelect";
|
||||||
|
import moment from "moment";
|
||||||
import OAuthWidget from "./common/OAuthWidget";
|
import OAuthWidget from "./common/OAuthWidget";
|
||||||
import SamlWidget from "./common/SamlWidget";
|
import SamlWidget from "./common/SamlWidget";
|
||||||
import RegionSelect from "./common/select/RegionSelect";
|
import RegionSelect from "./common/select/RegionSelect";
|
||||||
@ -869,6 +870,7 @@ class UserEditPage extends React.Component {
|
|||||||
<Col span={(Setting.isMobile()) ? 22 : 2} >
|
<Col span={(Setting.isMobile()) ? 22 : 2} >
|
||||||
<Switch checked={this.state.user.isDeleted} onChange={checked => {
|
<Switch checked={this.state.user.isDeleted} onChange={checked => {
|
||||||
this.updateUserField("isDeleted", checked);
|
this.updateUserField("isDeleted", checked);
|
||||||
|
this.updateUserField("deletedTime", checked ? moment().format() : "");
|
||||||
}} />
|
}} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -62,6 +62,7 @@ const userTemplate = {
|
|||||||
"name": "admin",
|
"name": "admin",
|
||||||
"createdTime": "2020-07-16T21:46:52+08:00",
|
"createdTime": "2020-07-16T21:46:52+08:00",
|
||||||
"updatedTime": "",
|
"updatedTime": "",
|
||||||
|
"deletedTime": "",
|
||||||
"id": "9eb20f79-3bb5-4e74-99ac-39e3b9a171e8",
|
"id": "9eb20f79-3bb5-4e74-99ac-39e3b9a171e8",
|
||||||
"type": "normal-user",
|
"type": "normal-user",
|
||||||
"password": "***",
|
"password": "***",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user