add models / services / handlers of user / token / 2fa, add web server command

This commit is contained in:
MaysWind
2020-10-17 20:01:24 +08:00
parent c9ae001aef
commit 60c31e8894
18 changed files with 1649 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
package models
import "github.com/mayswind/lab/pkg/core"
const TOKEN_USER_AGENT_MAX_LENGTH = 255
type TokenRecord struct {
Uid int64 `xorm:"PK"`
UserTokenId int64 `xorm:"PK"`
TokenType core.TokenType `xorm:"TINYINT NOT NULL"`
Secret string `xorm:"VARCHAR(10) NOT NULL"`
UserAgent string `xorm:"VARCHAR(255)"`
CreatedUnixTime int64 `xorm:"PK"`
ExpiredUnixTime int64
}
type TokenRevokeRequest struct {
TokenId string `json:"tokenId" binding:"required,notBlank"`
}
type TokenInfoResponse struct {
TokenId string `json:"tokenId"`
TokenType core.TokenType `json:"tokenType"`
UserAgent string `json:"userAgent"`
CreatedAt int64 `json:"createdAt"`
ExpiredAt int64 `json:"expiredAt"`
IsCurrent bool `json:"isCurrent"`
}