auth

package
v0.0.0-...-e78ca02 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword - calculates hash and error if not success

func IsCorrectPassword

func IsCorrectPassword(user *models.User, password string) bool

IsCorrectPassword returns true if password hashes are equal

Types

type Controller

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

Controller for user auth

func NewController

func NewController(userStorage UserStorage, jwtManager *crypta.JWTManager, logger logging.Logger) *Controller

func (*Controller) Login

func (c *Controller) Login(ctx context.Context, username string, password string) (*servicepb.LoginResponse, error)

Login by login and password

func (*Controller) Register

func (c *Controller) Register(ctx context.Context, username, password string) (*servicepb.RegisterResponse, error)

Register by login and password

type UserStorage

type UserStorage interface {
	SaveUser(ctx context.Context, user *models.User) error
	GetUser(ctx context.Context, username string) (*models.User, error)
}

UserStorage interface for saving user data

Jump to

Keyboard shortcuts

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