auther

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(passwordHash string, submittedPassword string) error

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a given password string using bcrypt with bcrypt DefaultCost

Types

type Repository

type Repository interface {
	Begin()
	Commit()
	Rollback()
	GetUserAuthByEmail(string) User
	GetUserAuthByID(int64) User
	UpdateUserRememberToken(User) int64
}

Repository provides access to User repository.

type Service

type Service interface {
	SignIn(UserSignIn) (string, error)
	CheckJWT(string) error
	GetCookiePayload(string) (UserJWT, error)
}

Service provides authing operations.

func NewService

func NewService(r Repository, key string) Service

NewService provides a new auth service

type User

type User struct {
	ID            int64
	PasswordHash  string
	RememberToken string
}

type UserChangePassword

type UserChangePassword struct {
	ID                int64
	CurrentPassword   string `schema:"currentPassword,required"`
	NewPassword       string `schema:"newPassword,required"`
	RepeatNewPassword string `schema:"repeatNewPassword,required"`
}

type UserJWT

type UserJWT struct {
	ID            int64  `json:"id"`
	RememberToken string `json:"rememberToken"`
}

type UserSignIn

type UserSignIn struct {
	Email    string
	Password string
}

Jump to

Keyboard shortcuts

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