更新用户退出功能
This commit is contained in:
17
config.yaml
Normal file
17
config.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
port: 9096
|
||||
database:
|
||||
username: "mayiming"
|
||||
password: "Mydream5654my,"
|
||||
host: "43.142.81.151"
|
||||
port: 3306
|
||||
params: "charset=utf8mb4&parseTime=True&loc=Local"
|
||||
redis:
|
||||
host: "localhost"
|
||||
port: 6379
|
||||
username: "default"
|
||||
password: ""
|
||||
jwtsecret: "clka1af83af15vhyt8s652avre"
|
||||
wxid: "wx25d0e3164c042c9d"
|
||||
wxsecret: "dd822f42589a373a3387e5778450f767"
|
||||
|
||||
|
||||
26
controllers/user/userLogout.go
Normal file
26
controllers/user/userLogout.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"toutoukan/init/redisInit"
|
||||
"toutoukan/utill"
|
||||
)
|
||||
|
||||
// 登出功能(从Redis删除令牌)
|
||||
func LogoutHandler(c *gin.Context) {
|
||||
tokenString := utill.ExtractTokenFromHeader(c)
|
||||
if tokenString == "" {
|
||||
c.JSON(400, gin.H{"error": "令牌不存在", "code": "10038"})
|
||||
return
|
||||
}
|
||||
|
||||
redisKey := fmt.Sprintf("jwt:%s", tokenString)
|
||||
err := redisInit.RedisClient.Del(redisInit.Ctx, redisKey).Err()
|
||||
if err != nil {
|
||||
c.JSON(500, gin.H{"error": "登出失败", "code": "10039"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{"code": "20002", "message": "登出成功"})
|
||||
}
|
||||
46
go.mod
46
go.mod
@@ -1,3 +1,49 @@
|
||||
module toutoukan
|
||||
|
||||
go 1.23.1
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/bytedance/sonic v1.14.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/gin-gonic/gin v1.10.1 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/go-sql-driver/mysql v1.9.3 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/minio/crc64nvme v1.0.2 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.95 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/philhofer/fwd v1.2.0 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
github.com/tinylib/msgp v1.3.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||
golang.org/x/arch v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.41.0 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
google.golang.org/protobuf v1.36.7 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
17
model/usermodel/userdata.go
Normal file
17
model/usermodel/userdata.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package usermodel
|
||||
|
||||
import "time"
|
||||
|
||||
type UserData struct {
|
||||
Uid string
|
||||
Username string
|
||||
Password string
|
||||
Email string
|
||||
Telephone string
|
||||
Avatar_url string
|
||||
Gender string
|
||||
Bio string
|
||||
Birth_date time.Time
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user