user

package
v0.0.0-...-b183724 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminEmail string
View Source
var ApiSecret string
View Source
var DevMode bool
View Source
var TokenExpiration int

Functions

func CreateToken

func CreateToken(email string) (string, error)

func DecryptGitToken

func DecryptGitToken(encryptedGitToken string) string

func EncryptGitToken

func EncryptGitToken(gitToken string) string

func ExtractToken

func ExtractToken(r *http.Request) string

func ExtractTokenID

func ExtractTokenID(token string) (string, error)

func Hash

func Hash(password string) ([]byte, error)

func Pretty

func Pretty(data interface{})

Pretty display the claims nicely in the terminal

func TokenClaims

func TokenClaims(token *jwt.Token) (jwt.MapClaims, error)

func TokenValid

func TokenValid(r *http.Request) (string, error)

Check if token is valid, if valid returns the associated email

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

Types

type GitProfile

type GitProfile struct {
	Name      string `json:"git_name"`
	Email     string `json:"git_email"`
	GitHandle string `json:"git_handle"`
	GitToken  string `json:"git_token"`
}

func GetGitProfile

func GetGitProfile(dbpool *pgxpool.Pool, userEmail string) (GitProfile, error)

type User

type User struct {
	Name      string    `json:"name"`
	Email     string    `json:"user_email"`
	Password  string    `json:"password"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Token     string    `json:"token"`
	DevMode   string    `json:"dev_mode"`

	IsActive       int        `json:"is_active"`
	UserGitProfile GitProfile `json:"gitProfile"`
	// contains filtered or unexported fields
}

func GetUserByEmail

func GetUserByEmail(dbpool *pgxpool.Pool, email string) (*User, error)

func GetUserByToken

func GetUserByToken(dbpool *pgxpool.Pool, token string) (*User, error)

func NewUser

func NewUser(email string) *User

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) GetCapabilities

func (u *User) GetCapabilities() []string

func (*User) HasCapability

func (u *User) HasCapability(capability string) bool

func (*User) InsertUser

func (u *User) InsertUser(dbpool *pgxpool.Pool) error

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) Prepare

func (u *User) Prepare()

func (*User) Validate

func (u *User) Validate(action string) error

Jump to

Keyboard shortcuts

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