user

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Admin = &User{
	Id:       0,
	Name:     "admin",
	Password: "admin",
}
View Source
var BearerSecurityScheme = "bearerAuth"
View Source
var SecuritySchemes = openapi.SecuritySchemes{
	BearerSecurityScheme: &openapi.SecurityScheme{
		Type: "apiKey",
		In:   "header",
		Name: "Authorization",
	},
}

Functions

func NewService

func NewService(secret string) *gins.Service

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() *DB

func (*DB) CreateUser

func (db *DB) CreateUser(u *User) (*User, error)

func (*DB) DeleteUser

func (db *DB) DeleteUser(id int)

func (*DB) GetUser

func (db *DB) GetUser(id int) *User

func (*DB) GetUsers

func (db *DB) GetUsers() []*User

func (*DB) Login

func (db *DB) Login(name, password string) *User

func (*DB) UpdateUser

func (db *DB) UpdateUser(u *User) (*User, error)

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

func NewHandlers

func NewHandlers(db *DB, auth *JWTAuth) *Handlers

func (*Handlers) Create

func (h *Handlers) Create() gins.Handler

func (*Handlers) Delete

func (h *Handlers) Delete() gins.Handler

func (*Handlers) Get

func (h *Handlers) Get() gins.Handler

func (*Handlers) List

func (h *Handlers) List() gins.Handler

func (*Handlers) Login

func (h *Handlers) Login() gins.Handler

func (*Handlers) Update

func (h *Handlers) Update() gins.Handler

type JWTAuth

type JWTAuth struct {
	// contains filtered or unexported fields
}

func NewJWTAuth

func NewJWTAuth(secretKey string) *JWTAuth

func (*JWTAuth) Auth

func (j *JWTAuth) Auth(c *gin.Context)

func (*JWTAuth) GenerateToken

func (j *JWTAuth) GenerateToken(user *User) (string, error)

func (*JWTAuth) GetToken

func (j *JWTAuth) GetToken(c *gin.Context) string

func (*JWTAuth) GetUser

func (j *JWTAuth) GetUser(c *gin.Context) *User

func (*JWTAuth) ParseToken

func (j *JWTAuth) ParseToken(tokenString string) (*User, error)

func (*JWTAuth) SecurityScheme

func (j *JWTAuth) SecurityScheme() []map[string][]string

type User

type User struct {
	Id       int    `json:"id" form:"id"`
	Name     string `json:"name" form:"name"`
	Password string `json:"password" form:"password"`
}

Jump to

Keyboard shortcuts

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