user

package
v0.0.0-...-fbda54b Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(ctx context.Context, client *ent.Client, input *model.LoginIn) (*ent.User, bool)

Authenticate for login

func AuthenticateByGoogle

func AuthenticateByGoogle(ctx context.Context, client *ent.Client, input *model.LoginByGoogleIn) (*ent.User, error)

func ChangePassword

func ChangePassword(ctx context.Context, client *ent.Client, id int, input *model.ChangePasswordIn) error

ChangePassword of current User

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compares raw password with it's hashed values

func CheckValidStatus

func CheckValidStatus(currentUser *ent.User) error

CheckValidStatus check if current user is in DEACTIVE status

func Count

func Count(ctx context.Context, client *ent.Client) (int, error)

Count return the count of all users

func Create

func Create(ctx context.Context, client *ent.Client, input *model.CreateUserIn) (*ent.User, error)

Create new User

func CreateInitUser

func CreateInitUser(ctx context.Context, client *ent.Client, initUser *model.CreateUserIn) error

CreateInitUser create un initial User for the application

func Delete

func Delete(ctx context.Context, client *ent.Client, id int) error

Delete a User

func ForgotPassword

func ForgotPassword(ctx context.Context, client *ent.Client, userEmail *string) error

ForgotPassword of the User

func GetUserContext

func GetUserContext(client *ent.Client, email string) (*ent.User, error)

GetUserContext of the current User

func GetUserIDByEmail

func GetUserIDByEmail(client *ent.Client, email string) (int, error)

GetUserIDByEmail check if a user exists in database by given email

func HasAnyPermission

func HasAnyPermission(user *ent.User, permissions []model.Permission) bool

HasAnyPermission check if user has any expected permission

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes given password

func RegisterUser

func RegisterUser(ctx context.Context, client *ent.Client, input *model.RegisterUserIn) (*ent.User, error)

RegisterUser new User

func ResetPassword

func ResetPassword(ctx context.Context, client *ent.Client, input *model.ResetPasswordIn) error

ResetPassword of the User

func Update

func Update(ctx context.Context, client *ent.Client, id int, input *model.UpdateUserIn) (*ent.User, error)

Update update an User

func UpdateCurrentUser

func UpdateCurrentUser(ctx context.Context, client *ent.Client, id int, input *model.UpdateCurrentUserIn) (*ent.User, error)

UpdateCurrentUser update all fields except password, permisions and status

func Users

func Users(ctx context.Context, client *ent.Client, input *model.UsersIn) (*ent.UserConnection, error)

Users filter users

Types

type EmailExists

type EmailExists struct{}

EmailExists error in the case create a new user with an email that exists

func (*EmailExists) Error

func (u *EmailExists) Error() string

type WrongEmailOrPasswordError

type WrongEmailOrPasswordError struct{}

WrongEmailOrPasswordError error in the case log in with wrong email or password

func (*WrongEmailOrPasswordError) Error

func (m *WrongEmailOrPasswordError) Error() string

Jump to

Keyboard shortcuts

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