auth

package
v0.0.0-...-71c9d12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser(c *gin.Context)

func Login

func Login(c *gin.Context)

处理用户登录请求

func Logout

func Logout(c *gin.Context)

func Register

func Register(name string, authenticator Authenticator)

Register 用于注册认证器

Types

type Authenticator

type Authenticator interface {
	Authenticate(authModel models.AuthModel) (*models.User, error)
}

Authenticator 定义了认证器的接口

type LoginData

type LoginData struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

用于绑定前端传递的登录请求体

type LoginResponse

type LoginResponse struct {
	Data LoginToken `json:"data"`
}

type LoginToken

type LoginToken struct {
	Token string `json:"token" binding:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL