usersvc

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoesUserExist

func DoesUserExist(ctx context.Context, Q *db.Queries, email string) (bool, error)

func GetUserByEmail

func GetUserByEmail(ctx context.Context, Q *db.Queries, email string) (*db.User, error)

func NewUser

func NewUser(ctx context.Context, Q *db.Queries,
	email string, password string, userData utils.JSONMap) (*db.User, error)

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	Token        string `json:"access_token"`
	TokenType    string `json:"token_type"` // Bearer
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

AccessTokenResponse represents an OAuth2 success response

type AccountContact

type AccountContact struct {
	FirstName string `json:"first"`
	LastName  string `json:"last"`
	Email     string `json:"email"`
	Company   string `json:"company"`
	Phone     string `json:"phone"`
}

type AccountInfo

type AccountInfo struct {
	ID       string         `json:"id"`
	Contact  AccountContact `json:"contact"`
	Language string         `json:"language"`
	Country  string         `json:"country"`
}

type AppUser

type AppUser struct {
	UserType    string      `json:"user_type"`
	Updated     time.Time   `json:"updated"`
	Reseller    string      `json:"reseller"`
	AccountInfo AccountInfo `json:"account_info"`
}

type ConfirmEmailInfo

type ConfirmEmailInfo struct {
	FirstName string
	Link      string
}

type ConfirmEmailResponse

type ConfirmEmailResponse struct {
	ResetPasswordToken string `json:"reset_token"`
	Status             string `json:"status"`
}

type EmailUpdateInfo

type EmailUpdateInfo struct {
	FirstName string
	Link      string
}

type MyJWTClaims

type MyJWTClaims struct {
	jwt.StandardClaims
	Email        string                 `json:"email"`
	AppMetaData  map[string]interface{} `json:"app_metadata"`
	UserMetaData map[string]interface{} `json:"user_metadata"`
}

TODO: Remove unnecessary data from JWT token (such as Email) Holds JWT claims

type PasswordLoginParams

type PasswordLoginParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ResetPasswordInfo

type ResetPasswordInfo struct {
	FirstName string
	Link      string
}

type SignupParams

type SignupParams struct {
	Email    string                 `json:"email"`
	Password string                 `json:"password"`
	Data     map[string]interface{} `json:"data"`
	Provider string                 `json:"-"`
}

SignupParams are the parameters the Signup endpoint accepts

type UserAccountResponse

type UserAccountResponse struct {
	UserID string `json:"user_id"`
}

type UserInfo

type UserInfo struct {
	AppUser                     AppUser `json:"app_user"`
	ResetPasswordOnConfirmation bool    `json:"reset_password_on_confirmation"`
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func New

func New(svc *service.Service) *UserService

func (*UserService) AdminLoginAs

func (usvc *UserService) AdminLoginAs(ctx context.Context, email string) (*AccessTokenResponse, error)

func (*UserService) AuthenticateExternalUser

func (usvc *UserService) AuthenticateExternalUser(ctx context.Context,
	userInfo *external.UserProvidedData) (*AccessTokenResponse, error)

func (*UserService) CompleteEmailUpdate

func (usvc *UserService) CompleteEmailUpdate(ctx context.Context, token string) error

func (*UserService) ConfirmUserEmail

func (usvc *UserService) ConfirmUserEmail(ctx context.Context, code string) (*ConfirmEmailResponse, error)

func (*UserService) DeleteAPIKey

func (usvc *UserService) DeleteAPIKey(ctx context.Context, apiKey string, userID string) error

func (*UserService) GetAPIKeys

func (usvc *UserService) GetAPIKeys(ctx context.Context, userID string) ([]db.GetAPIKeysRow, error)

func (*UserService) GetUser

func (usvc *UserService) GetUser(ctx context.Context, strID string) (*db.User, error)

func (*UserService) GetUserFromAPIKey

func (usvc *UserService) GetUserFromAPIKey(ctx context.Context, apiKey string) (*db.User, error)

func (*UserService) GetUserIDFromAPIKey

func (usvc *UserService) GetUserIDFromAPIKey(apiKey string) (string, error)

func (*UserService) GetUsersCreatedNDaysAgo

func (usvc *UserService) GetUsersCreatedNDaysAgo(ctx context.Context, days int32) ([]db.GetUsersSignedUpNDaysAgoRow, error)

func (*UserService) InitResetPasswordRequest

func (usvc *UserService) InitResetPasswordRequest(ctx context.Context, email string) error

func (*UserService) NewAPIKey

func (usvc *UserService) NewAPIKey(ctx context.Context, userID string) (string, error)

func (*UserService) PasswordLogin

func (usvc *UserService) PasswordLogin(ctx context.Context, params *PasswordLoginParams) (*AccessTokenResponse, error)

func (*UserService) PostConfirmationEmail

func (usvc *UserService) PostConfirmationEmail(userID string)

func (*UserService) PostEmailUpdateConfirmation

func (usvc *UserService) PostEmailUpdateConfirmation(userID string, email string)

func (*UserService) PostPasswordResetEmail

func (usvc *UserService) PostPasswordResetEmail(email string)

func (*UserService) RenewRefreshToken

func (usvc *UserService) RenewRefreshToken(ctx context.Context,
	current_token string) (*AccessTokenResponse, error)

func (*UserService) ResetPassword

func (usvc *UserService) ResetPassword(ctx context.Context, token string, passwd string) error

func (*UserService) SendEmailConfirmationRequest

func (usvc *UserService) SendEmailConfirmationRequest(ctx context.Context, userID string) error

func (*UserService) Shutdown

func (usvc *UserService) Shutdown()

func (*UserService) SignupNewUser

func (this *UserService) SignupNewUser(ctx context.Context, params *SignupParams) (*db.User, error)

func (*UserService) SwitchToFreeAccount

func (usvc *UserService) SwitchToFreeAccount(ctx context.Context, email string) (*UserAccountResponse, error)

func (*UserService) UpdateAppUser

func (usvc *UserService) UpdateAppUser(ctx context.Context, userID string,
	appUser *AppUser, resetPasswordOnConfirmation bool) error

func (*UserService) UpdatePassword

func (usvc *UserService) UpdatePassword(ctx context.Context, user *db.User, oldPassword string, newPassword string) error

func (*UserService) UpdateProfileField

func (usvc *UserService) UpdateProfileField(ctx context.Context, user *db.User,
	fieldName string, fieldValue string) error

func (*UserService) UpdateUserAccount

func (usvc *UserService) UpdateUserAccount(ctx context.Context, email string, appUser *AppUser) (*UserAccountResponse, error)

Jump to

Keyboard shortcuts

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