user

package
v0.0.0-...-932f57c Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdministrador = "Administrador"
	RoleLogged        = "Logged"
)
View Source
const MessagesKey i18n.ModuleKey = "admin/helper/user"

Variables

View Source
var (
	Messages_en_US = &Messages{
		User:                              "User",
		Users:                             "Users",
		UserCreatedAt:                     "Created",
		UserName:                          "Name",
		UserStatus:                        "Status",
		UserRegistrationDate:              "Registration date",
		UserRegistrationDateRange:         "Registration date Range",
		AllSessionLogsExpiredSuccessfully: "All session logs expired successfully",
		UserUnlockedSuccessfully:          "User Unlocked Successfully",
		MailSentSuccessfully:              "Email sent successfully",
		ErrorAccountRequired:              "Account/Email required",
		Active:                            "Active",
		Inactive:                          "Inactive",
		Actives:                           "Actives",
		Inactives:                         "Inactives",
	}

	Messages_pt_BR = &Messages{
		User:                              "Usuário",
		Users:                             "Usuários",
		UserCreatedAt:                     "Cadastro",
		UserName:                          "Nome",
		UserStatus:                        "Situação",
		UserRegistrationDate:              "Registro",
		UserRegistrationDateRange:         "Período de Registro",
		AllSessionLogsExpiredSuccessfully: "Você foi desconectado de todas as sessões ativas",
		UserUnlockedSuccessfully:          "Usuário desbloqueado com sucesso",
		ErrorAccountRequired:              "Nome da conta/Email é obrigatório",
		MailSentSuccessfully:              "Email enviado com sucesso",
		Active:                            "Ativo",
		Inactive:                          "Inativo",
		Actives:                           "Ativos",
		Inactives:                         "Inativos",
	}
)

Functions

func ConfigureChangePasswordAction

func ConfigureChangePasswordAction(lb *login.Builder, currentPasswordCheck bool, d *presets.DetailingBuilder, getUser func(ctx *web.EventContext) (u User, err error))

func ConfigureMessages

func ConfigureMessages(b *i18n.Builder)

func DefaultModelOptions

func DefaultModelOptions(opts ...presets.ModelBuilderOption) []presets.ModelBuilderOption

func FindRoles

func FindRoles(db *gorm.DB, u User) (roles []*role.Role)

Types

type Builder

type Builder struct {
	ExpireAllSessionLogs  func(db *gorm.DB, userID uint) (err error)
	LoginInitialUserEmail string
	Roles                 []string
	UserManagerRoles      []string
	// contains filtered or unexported fields
}

func New

func New(db *gorm.DB, lb *login.Builder, mb *presets.ModelBuilder, loginInitialUserEmail string) (c *Builder)

func (*Builder) AppendRoles

func (b *Builder) AppendRoles(roles ...string) *Builder

func (*Builder) GenInitialUser

func (b *Builder) GenInitialUser(db *gorm.DB) (user User)

func (*Builder) GrantUserRole

func (b *Builder) GrantUserRole(db *gorm.DB, userID uint, roleName string) error

func (*Builder) InitDefaultRoles

func (b *Builder) InitDefaultRoles(db *gorm.DB) error

func (*Builder) Middlewares

func (b *Builder) Middlewares(db *gorm.DB, logoutURL string, checkIsTokenValidFromRequest func(db *gorm.DB, r *http.Request, userID uint) (valid bool, err error)) *Middlewares

func (*Builder) UserRoles

func (b *Builder) UserRoles(u User) (roles []string)

type ChangePassword

type ChangePassword struct {
	OldPassword     string `admin:"required"`
	NewPassword     string `admin:"required"`
	ConfirmPassword string `admin:"required"`
}

type Messages

type Messages struct {
	User                      string
	Users                     string
	UserCreatedAt             string
	UserName                  string
	UserStatus                string
	UserRegistrationDate      string
	UserRegistrationDateRange string
	MailSentSuccessfully      string

	AllSessionLogsExpiredSuccessfully string
	UserUnlockedSuccessfully          string

	ErrorAccountRequired string
	Active               string
	Inactive             string
	Actives              string
	Inactives            string
}

func GetMessages

func GetMessages(ctx context.Context) *Messages

type Middlewares

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

func (*Middlewares) DevMode

func (b *Middlewares) DevMode() bool

func (*Middlewares) Middleware

func (b *Middlewares) Middleware(next http.Handler) http.Handler

func (*Middlewares) MiddlewareMD

func (b *Middlewares) MiddlewareMD() func(next http.Handler) http.Handler

func (*Middlewares) Security

func (b *Middlewares) Security(next http.Handler) http.Handler

func (*Middlewares) SecurityMD

func (b *Middlewares) SecurityMD() func(next http.Handler) http.Handler

func (*Middlewares) SetDevMode

func (b *Middlewares) SetDevMode(v bool) *Middlewares

func (*Middlewares) ValidateSessionToken

func (b *Middlewares) ValidateSessionToken(next http.Handler) http.Handler

func (*Middlewares) ValidateSessionTokenMD

func (b *Middlewares) ValidateSessionTokenMD() func(next http.Handler) http.Handler

func (*Middlewares) WithRoles

func (b *Middlewares) WithRoles(next http.Handler) http.Handler

func (*Middlewares) WithRolesMD

func (b *Middlewares) WithRolesMD() func(next http.Handler) http.Handler

type User

type User interface {
	login.UserPasser
	GetID() uint
	GetName() string
	SetName(v string)
	SetEmail(v string)
	SetRegistrationDate(v time.Time)
	GetStatus() string
	GetAccountName() string
	GetRoles() role.Roles
	SetRoles(roles role.Roles)
}

func GetCurrentUser

func GetCurrentUser(r *http.Request) (u User)

Jump to

Keyboard shortcuts

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