user

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmailAddressInvalid = credstackError.NewError(400, "EMAIL_ADDRESS_INVALID", "email: Invalid email address")

ErrEmailAddressInvalid - Provides a named error that occurs when the caller attempts to register a user with an improperly formatted email address

View Source
var ErrFailedToHashCredential = credstackError.NewError(500, "FAILED_TO_HASH_CREDENTIAL", "user: failed to hash user credential")

ErrFailedToHashCredential - Provides a named error for when user credential hashing has failed

View Source
var ErrPasswordTooLong = credstackError.NewError(400, "CRED_PASS_TOO_LONG", "credential: password too long")

ErrPasswordTooLong - Provides a named error to be returned when a user-provided password is too long

View Source
var ErrPasswordTooShort = credstackError.NewError(400, "CRED_PASS_TOO_SHORT", "credential: password too short")

ErrPasswordTooShort - Provides a named error to be returned when a user-provided password is too short

View Source
var ErrUserAlreadyExists = credstackError.NewError(409, "USER_ALREADY_EXISTS", "user: User already exists under the specified email address")

ErrUserAlreadyExists - Provides a named error that occurs when you try and duplicate a user

View Source
var ErrUserCredentialInvalid = credstackError.NewError(401, "INVALID_USER_CREDENTIAL", "user: invalid credentials")

ErrUserCredentialInvalid - Provides a named error for when user credential validation fails

View Source
var ErrUserDoesNotExist = credstackError.NewError(404, "USER_DOES_NOT_EXIST", "user: user does not exist under the specified email address")

ErrUserDoesNotExist - Provides a named error for when operations fail due to the user account not existing

View Source
var ErrUserMissingIdentifier = credstackError.NewError(400, "USER_MISSING_ID", "user: User is either missing a username or an email address")

ErrUserMissingIdentifier - Provides a named error that gets thrown when you try and create a new user without an Email

Functions

func CheckCredential

func CheckCredential(validate string, credential *user.UserCredential) error

CheckCredential - Validates the base64 encoded secret passed in the 'validate' parameter against the UserCredential struct passed in the credential parameter. This should be a UserCredential struct returned from a call to GetUser. If the user credentials do not match, then ErrUserCredentialInvalid is returned. Otherwise, nil is returned

func DeleteUser

func DeleteUser(serv *server.Server, email string) error

DeleteUser - Completely removes a user account from CredStack. A valid email address must be passed in this parameter, or it will return ErrUserMissingIdentifier. If the deleted count returned is equal to zero, then the function considers the user to not exist. A successful call to this function will return nil

func GetUser

func GetUser(serv *server.Server, email string, withCredentials bool) (*userModel.User, error)

GetUser - Fetches a user from the database and returns it's protobuf model for it. If you are fetching a user without its credentials, then set withCredentials to false. Projection is used on this field to prevent it from leaving the database due to its sensitive information

func ListUser

func ListUser(serv *server.Server, limit int, withCredentials bool) ([]*userModel.User, error)

ListUser - Lists all users present in the database. Optionally, a limit can be specified here to limit the amount of data returned at once. The maximum that can be returned in a single call is 10, and if a limit exceeds this, it will be reset to 10

func NewCredential

func NewCredential(credential string, opts *options.CredentialOptions) (*user.UserCredential, error)

NewCredential - Creates and generates a new UserCredential using the secret provided in the parameter. Both the secret and the salt are stored as URL-Safe, base64 encoded strings to ensure that they can be safely stored in Mongo. Any errors that occur here are returned in the wrapped error: ErrFailedToHashCredential.

func RegisterUser

func RegisterUser(serv *server.Server, opts *options.CredentialOptions, email string, username string, password string) error

RegisterUser - Core logic for registering new users with credstack. Performs full validation on any of the user data provided here. New users must have a unique email address and this will be validated here. Any errors propagated through this function call is returned. This is generally only named errors defined in this package.

func UpdateUser

func UpdateUser(serv *server.Server, email string, patch *userModel.User) error

UpdateUser - Provides functionality for updating a select number of fields of the user model. A valid email address must be provided as an argument for this function call. Fields to update can be passed in the patch parameter. The following fields can be updated: Username, GivenName, FamilyName, Gender, BirthDate, and Address. If you need to update a different field (like email), then use the dedicated functions for this

Types

This section is empty.

Jump to

Keyboard shortcuts

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