rdb新增用户添加时间代码调整 (#398)

* rdb资源增加volume

* rdb用户增加创建时间

* rdb用户添加时间

* rdb新增添加用户时间代码调整

* test

Co-authored-by: alickliming <alickliming@didi.global.com>
This commit is contained in:
alick-liming 2020-11-13 14:18:49 +08:00 committed by GitHub
parent 1a71de851a
commit ffc98f31c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View File

@ -19,7 +19,7 @@ CREATE TABLE `user`
`is_root` tinyint(1) not null, `is_root` tinyint(1) not null,
`leader_id` int unsigned not null default 0, `leader_id` int unsigned not null default 0,
`leader_name` varchar(32) not null default '', `leader_name` varchar(32) not null default '',
`create_at` int unsigned not null default 0, `create_at` timestamp not null default CURRENT_TIMESTAMP,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY (`username`), UNIQUE KEY (`username`),
UNIQUE KEY (`uuid`) UNIQUE KEY (`uuid`)

View File

@ -41,7 +41,7 @@ type User struct {
IsRoot int `json:"is_root"` IsRoot int `json:"is_root"`
LeaderId int64 `json:"leader_id"` LeaderId int64 `json:"leader_id"`
LeaderName string `json:"leader_name"` LeaderName string `json:"leader_name"`
CreateAt int64 `json:"create_at"` CreateAt time.Time `json:"create_at" xorm:"<-"`
} }
func (u *User) CopyLdapAttr(sr *ldap.SearchResult) { func (u *User) CopyLdapAttr(sr *ldap.SearchResult) {

View File

@ -64,7 +64,6 @@ func userAddPost(c *gin.Context) {
IsRoot: f.IsRoot, IsRoot: f.IsRoot,
LeaderId: f.LeaderId, LeaderId: f.LeaderId,
UUID: models.GenUUIDForUser(f.Username), UUID: models.GenUUIDForUser(f.Username),
CreateAt: time.Now().Unix(),
} }
if f.LeaderId != 0 { if f.LeaderId != 0 {
@ -273,8 +272,7 @@ func userInvitePost(c *gin.Context) {
inv, err := models.InviteGet("token=?", f.Token) inv, err := models.InviteGet("token=?", f.Token)
dangerous(err) dangerous(err)
now := time.Now().Unix() if inv.Expire < time.Now().Unix() {
if inv.Expire < now {
dangerous("invite url already expired") dangerous("invite url already expired")
} }
@ -285,7 +283,6 @@ func userInvitePost(c *gin.Context) {
Email: f.Email, Email: f.Email,
Im: f.Im, Im: f.Im,
UUID: models.GenUUIDForUser(f.Username), UUID: models.GenUUIDForUser(f.Username),
CreateAt: now,
} }
u.Password, err = models.CryptoPass(f.Password) u.Password, err = models.CryptoPass(f.Password)