mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
refactor: login & refresh token
This commit is contained in:
18
model/api.go
18
model/api.go
@@ -23,17 +23,17 @@ func (r ServiceItemResponse) TotalUptime() float32 {
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type CommonError struct {
|
||||
Code int `json:"code"`
|
||||
Args map[string]string `json:"args"`
|
||||
type CommonResponse[T any] struct {
|
||||
Success bool `json:"success,omitempty"`
|
||||
Data T `json:"data,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type CommonResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Data interface{} `json:"data"`
|
||||
Error CommonError `json:"error"`
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
Expire string `json:"expire,omitempty"`
|
||||
}
|
||||
|
||||
@@ -7,15 +7,12 @@ import (
|
||||
)
|
||||
|
||||
const CtxKeyAuthorizedUser = "ckau"
|
||||
const CtxKeyViewPasswordVerified = "ckvpv"
|
||||
const CtxKeyPreferredTheme = "ckpt"
|
||||
const CacheKeyOauth2State = "p:a:state"
|
||||
|
||||
type Common struct {
|
||||
ID uint64 `gorm:"primaryKey"`
|
||||
CreatedAt time.Time `gorm:"index;<-:create"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
ID uint64 `gorm:"primaryKey" json:"id,omitempty"`
|
||||
CreatedAt time.Time `gorm:"index;<-:create" json:"created_at,omitempty"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
|
||||
@@ -117,6 +117,9 @@ func (c *Config) Read(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.ListenPort == 0 {
|
||||
c.ListenPort = 8008
|
||||
}
|
||||
if c.Language == "" {
|
||||
c.Language = "zh-CN"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ package model
|
||||
|
||||
type User struct {
|
||||
Common
|
||||
Username string
|
||||
Password string
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty" gorm:"type:char(72)"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user