auth

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

AuthRequired middleware проверяет аутентификацию пользователя

func RegisterRoutes

func RegisterRoutes(r *gin.Engine, db *gorm.DB)

Types

type AuthHandler

type AuthHandler struct {
	DB *gorm.DB
}

func NewAuthHandler

func NewAuthHandler(db *gorm.DB) *AuthHandler

func (*AuthHandler) Login

func (h *AuthHandler) Login(c *gin.Context)

Login обрабатывает вход пользователя

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(c *gin.Context)

Logout обрабатывает выход пользователя

func (*AuthHandler) Register

func (h *AuthHandler) Register(c *gin.Context)

Register обрабатывает регистрацию пользователя

func (*AuthHandler) WhoI added in v0.1.5

func (h *AuthHandler) WhoI(c *gin.Context)

WhoI возвращает информацию о текущем пользователе

type Role added in v0.1.5

type Role struct {
	gorm.Model
	Name string `gorm:"unique;not null"`
}

type RoleController added in v0.1.5

type RoleController struct {
	*go4rest.ViewSet[Role]
	// contains filtered or unexported fields
}

func NewRoleController added in v0.1.5

func NewRoleController(db *gorm.DB) *RoleController

type User

type User struct {
	ID       int    `json:"id"`
	Username string `gorm:"unique;not null"`
	Password string `gorm:"not null" json:"-"`
	RoleID   uint
	Role     Role `gorm:"foreignKey:RoleID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

CheckPassword проверяет соответствие пароля хешу

func (*User) HashPassword

func (u *User) HashPassword() error

HashPassword хеширует пароль перед сохранением

type UserController added in v0.1.5

type UserController struct {
	*go4rest.ViewSet[User]
	// contains filtered or unexported fields
}

func NewUserController added in v0.1.5

func NewUserController(db *gorm.DB) *UserController

Jump to

Keyboard shortcuts

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