auth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 6 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) Profile

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

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

func (*AuthHandler) Register

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

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

type User

type User struct {
	gorm.Model
	Username string `gorm:"unique;not null"`
	Password string `gorm:"not null"`
}

func (*User) CheckPassword

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

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

func (*User) HashPassword

func (u *User) HashPassword() error

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

Jump to

Keyboard shortcuts

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