auth

package
v0.0.0-...-ef5e7fb Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

Checks if the password is same as the hashed password

func HashPassword

func HashPassword(password string) (string, error)

Hashes the password

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Represents the claims of the JWT token

func ValidateToken

func ValidateToken(tokenString string, jwtSecret []byte) (*Claims, error)

type LoginHandler

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

func NewLoginHandler

func NewLoginHandler(service *LoginService) *LoginHandler

func (*LoginHandler) LoginHandler

func (h *LoginHandler) LoginHandler(c *gin.Context)

LoginHandler, Login kullanıcılarının giriş yapmasına olanak tanır. @Summary Login login @Description Authenticates an Login user and returns a JWT token. @Tags Auth @Accept json @Produce json @Param Login body auth.LoginRequest true "Login login credentials" @Success 200 {object} models.TokenResponse "JWT token" @Failure 400 {object} models.ErrorResponse "Invalid request" @Failure 401 {object} models.ErrorResponse "Invalid username or password" @Router /Login/login [post]

type LoginRequest

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

type LoginService

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

func NewLoginService

func NewLoginService(userRepo UserRepository, jwtSecret []byte) *LoginService

func (*LoginService) AuthenticateAdmin

func (s *LoginService) AuthenticateAdmin(username, password string) (string, error)

type UserRepository

type UserRepository interface {
	FindByUsername(username string) (*models.User, error)
}

func NewUserRepository

func NewUserRepository(db *gorm.DB) UserRepository

Jump to

Keyboard shortcuts

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