domain

package
v0.0.0-...-f2344d4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(username string) (string, error)

GetToken returns a JWT token with the username as a claim

func ValidateToken

func ValidateToken(token string) (bool, error)

ValidateToken validates if a JWT is correct

Types

type Claims

type Claims struct {
	Username string
	jwt.StandardClaims
}

Claims defines the values we will add to the JWT claims

type Credentials

type Credentials struct {
	Username string
	Password string
	Email    string
}

Credentials defines the necessary parameters for a user to sign in and sign up

func (*Credentials) Validate

func (credentials *Credentials) Validate() bool

Validate checks that the required values of the credentials are filled and that they meet specific requirements

type User

type User struct {
	ID       uuid.UUID
	FullName string
	Username string
	Password string
	Email    string
	Score    int
	GitHubID string
}

User is the domain entity that defines a user of the application

type UserRepo

type UserRepo interface {
	FindByUsername(username string) (*User, error)
	FindByID(id uuid.UUID) (*User, error)
	Create(u *User) (*User, error)
	CheckEmail(email string) bool
	CheckUsername(username string) bool
}

UserRepo is the interface that defines all of the operations the User entity can do with the persistance layer

Jump to

Keyboard shortcuts

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