userService

package
v0.0.0-...-dffa276 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 18 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateUser

func ActivateUser(c *gin.Context) (model.User, int, error)

ActivateUser toggle activation of a user.

func AddRoleToUser

func AddRoleToUser(c *gin.Context) (int, error)

AddRoleToUser adds a role to a user.

func ClearCookie

func ClearCookie(c *gin.Context) (int, error)

ClearCookie clears a cookie.

func CreateUser

func CreateUser(c *gin.Context) (int, error)

CreateUser creates a user.

func CreateUserAuthentication

func CreateUserAuthentication(c *gin.Context) (int, error)

CreateUserAuthentication creates user authentication.

func CreateUserFromForm

func CreateUserFromForm(registrationForm RegistrationForm) (model.User, error)

CreateUserFromForm creates a user from a registration form.

func CurrentUser

func CurrentUser(c *gin.Context) (model.User, error)

func CurrentUserByToken

func CurrentUserByToken(token string) (model.User, error)

func DeleteUser

func DeleteUser(c *gin.Context) (int, error)

DeleteUser deletes a user.

func EmailVerification

func EmailVerification(c *gin.Context) (int, error)

EmailVerification verifies an email of user.

func GetAuthToken

func GetAuthToken(c *gin.Context) (string, error)

func RegisterHanderFromForm

func RegisterHanderFromForm(c *gin.Context, registrationForm RegistrationForm) (int, error)

RegisterHanderFromForm sets cookie from a RegistrationForm.

func RegisterHandler

func RegisterHandler(c *gin.Context) (int, error)

RegisterHandler sets a cookie when user registered.

func RemoveRoleFromUser

func RemoveRoleFromUser(c *gin.Context) (int, error)

RemoveRoleFromUser removes a role from a user.

func ResetPassword

func ResetPassword(c *gin.Context) (int, error)

ResetPassword resets a password of user.

func RetrieveCurrentUser

func RetrieveCurrentUser(c *gin.Context) (model.User, int, error)

RetrieveCurrentUser retrieves a current user.

func RetrieveUser

func RetrieveUser(c *gin.Context) (*model.PublicUser, bool, uint, int, error)

RetrieveUser retrieves a user.

func RetrieveUserByEmail

func RetrieveUserByEmail(c *gin.Context) (*model.PublicUser, string, int, error)

RetrieveUserByEmail retrieves a user by an email

func RetrieveUserByUsername

func RetrieveUserByUsername(c *gin.Context) (*model.PublicUser, string, int, error)

RetrieveUserByUsername retrieves a user by username.

func RetrieveUserForAdmin

func RetrieveUserForAdmin(c *gin.Context) (model.User, int, error)

RetrieveUserForAdmin retrieves a user for an administrator.

func RetrieveUsers

func RetrieveUsers(c *gin.Context) []*model.PublicUser

RetrieveUsers retrieves users.

func RetrieveUsersByEmail

func RetrieveUsersByEmail(c *gin.Context) []*model.PublicUser

RetrieveUsersByEmail retrieves users by an email

func RetrieveUsersForAdmin

func RetrieveUsersForAdmin(c *gin.Context) []model.User

RetrieveUsersForAdmin retrieves users for an administrator.

func SendEmailPasswordResetToken

func SendEmailPasswordResetToken(to string, token string, locale string) error

SendEmailPasswordResetToken sends a password reset token via email.

func SendEmailVerfication

func SendEmailVerfication(to string, token string, locale string) error

SendEmailVerfication sends an email verification token via email.

func SendPasswordResetToken

func SendPasswordResetToken(c *gin.Context) (int, error)

SendPasswordResetToken sends a password reset token.

func SendVerification

func SendVerification(c *gin.Context) (int, error)

SendVerification sends an email verification token.

func SendVerificationToUser

func SendVerificationToUser(user model.User) (int, error)

SendVerificationToUser sends an email verification token to user.

func SetCookie

func SetCookie(c *gin.Context, token string) (int, error)

SetCookie sets a cookie.

func SetCookieHandler

func SetCookieHandler(c *gin.Context, email string, pass string) (int, error)

SetCookieHandler sets a cookie with email and password.

func SuggestUsername

func SuggestUsername(username string) string

SuggestUsername suggest user's name if user's name already occupied.

func Token

func Token(c *gin.Context) (string, error)

func UpdateUser

func UpdateUser(c *gin.Context) (*model.User, int, error)

UpdateUser updates a user.

func UpdateUserCore

func UpdateUserCore(user *model.User) (int, error)

UpdateUserCore updates a user. (Applying the modifed data of user).

Types

type ActivateForm

type ActivateForm struct {
	Activation bool `form:"activation" binding:"required"`
}

ActivateForm is used when activating user.

type LoginForm

type LoginForm struct {
	Email    string `form:"loginEmail" binding:"required"`
	Password string `form:"loginPassword" binding:"required"`
}

RegistrationForm is used when creating a user authentication.

type PasswordForm

type PasswordForm struct {
	CurrentPassword string `form:"currentPassword" binding:"required"`
	Password        string `form:"newPassword" binding:"required"`
}

PasswordForm is used when updating a user password.

type PasswordResetForm

type PasswordResetForm struct {
	PasswordResetToken string `form:"token" binding:"required"`
	Password           string `form:"newPassword" binding:"required"`
}

PasswordResetForm is used when reseting a password.

type RegistrationForm

type RegistrationForm struct {
	Username string `form:"registrationUsername" binding:"required"`
	Email    string `form:"registrationEmail" binding:"required"`
	Password string `form:"registrationPassword" binding:"required"`
}

RegistrationForm is used when creating a user.

type SendPasswordResetForm

type SendPasswordResetForm struct {
	Email string `form:"email" binding:"required"`
}

SendPasswordResetForm is used when sending a password reset token.

type UserForm

type UserForm struct {
	Age  uint   `form:"age"`
	Name string `form:"name" binding:"required"`
}

UserForm is used when updating a user.

type UserRoleForm

type UserRoleForm struct {
	UserId int `form:"userId" binding:"required"`
	RoleId int `form:"roleId" binding:"required"`
}

UserRoleForm is used when adding or removing a role from a user.

type VerifyEmailForm

type VerifyEmailForm struct {
	ActivationToken string `form:"token" binding:"required"`
}

VerifyEmailForm is used when verifying an email.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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