管理员和用户状态为不可用时,删除已生成的API令牌

This commit is contained in:
GoEdgeLab
2022-12-02 17:33:45 +08:00
parent 2ee1ee9387
commit e91d593081
4 changed files with 50 additions and 6 deletions

View File

@@ -81,3 +81,16 @@ func (this *APIAccessTokenDAO) FindAccessToken(tx *dbs.Tx, token string) (*APIAc
}
return one.(*APIAccessToken), nil
}
// DeleteAccessTokens 删除用户的令牌
func (this *APIAccessTokenDAO) DeleteAccessTokens(tx *dbs.Tx, adminId int64, userId int64) error {
var query = this.Query(tx)
if adminId > 0 {
query.Attr("adminId", adminId)
} else if userId > 0 {
query.Attr("userId", userId)
} else {
return nil
}
return query.DeleteQuickly()
}