auth

package
v0.0.0-...-b8d8853 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRefreshToken

func GenerateRefreshToken(userID string) (string, *ec.Error)

func GenerateToken

func GenerateToken(userID string) (string, *ec.Error)

func VerifyEmail

func VerifyEmail(token string) (bool, *ec.Error)

func VerifyRefreshToken

func VerifyRefreshToken(refreshTknStr string) (string, *ec.Error)

Types

type LoginInput

type LoginInput struct {
	Email    string `json:"email"    validate:"required,email" example:"john.doe@gmail.com"`
	Password string `json:"password" validate:"required"       example:"1234qwer"`
}

type RegisterInput

type RegisterInput struct {
	Email           string `json:"email"                validate:"required,email"            example:"john.doe@gmail.com"`
	Password        string `json:"password"             validate:"required"                  example:"1234qwer"`
	PasswordConfirm string `json:"password_confirm"     validate:"required,eqfield=Password" example:"1234qwer"`
	FirstName       string `json:"first_name,omitempty" validate:"required"                  example:"John"`
	LastName        string `json:"last_name,omitempty"  validate:"required"                  example:"Doe"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

func Login

func Login(body []byte) (*TokenResponse, *ec.Error)

func RefreshToken

func RefreshToken(r *http.Request) (*TokenResponse, *ec.Error)

type User

type User struct {
	ID              string         `json:"id"`
	FirstName       sql.NullString `json:"first_name"`
	LastName        sql.NullString `json:"last_name"`
	Email           string         `json:"email"`
	EmailHash       string         `json:"-"`
	EmailVerifiedAt sql.NullTime   `json:"email_verified_at"`
	Password        string         `json:"-"`
	CreatedAt       sql.NullTime   `json:"created_at"`
	UpdatedAt       sql.NullTime   `json:"updated_at"`
	DeletedAt       sql.NullTime   `json:"deleted_at"`
}

User a clone of queries.User{} from sqlc/queries/models.go

func Register

func Register(r *http.Request, body []byte) (*User, *ec.Error)

func (*User) DecryptEmail

func (u *User) DecryptEmail() (string, error)

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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