user

package module
v0.0.0-...-88a898d Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 37 Imported by: 1

README

user

User resources for https://github.com/ecletus framework

Documentation

Index

Constants

View Source
const (
	ActionLogout     = "Logout"
	ActionBulkLogout = "BulkLogout"
)
View Source
const AdminUserName = "admin"
View Source
const DEFAULT_PASSWORD = "123@456"

Variables

View Source
var (
	USER_MENU     = PKG + ".menu.user"
	GROUP_MENU    = PKG + ".menu.group"
	LOGOUTERS_KEY = PKG + ".logouters"
)
View Source
var E_REGISTER_USER = PKG + ".register_user"
View Source
var (
	PKG = path_helpers.GetCalledDir()
)

Functions

func AdminFlagCommand

func AdminFlagCommand(cu *sites.CmdUtils, authGetter func() *auth.Auth, preRun ...func()) (cmd *cobra.Command)

func AdminFlagCommandChanger

func AdminFlagCommandChanger(cu *sites.CmdUtils, authGetter func() *auth.Auth, enable bool, preRun ...func()) (cmd *cobra.Command)

func CreateAdminUserIfNotExists

func CreateAdminUserIfNotExists(site *core.Site, Auth *auth.Auth, Notification *notification.Notification,
	readEmail func() (string, error), readPassword func() (string, error)) (err error)

func CreateCommands

func CreateCommands(register *core.SitesRegister, authGetter func() *auth.Auth, preRun ...func()) (cmds []*cobra.Command, err error)

func EqualsRoleChecker

func EqualsRoleChecker(roleName string) roles.Checker

func Events

func Events(d plug.PluginEventDispatcherInterface) *events

func GetGroupResource

func GetGroupResource(Admin *admin.Admin) *admin.Resource

func GetResource

func GetResource(Admin *admin.Admin) *admin.Resource

func I18n

func I18n(key ...string) string

func PasswordResetterCommand

func PasswordResetterCommand(cu *sites.CmdUtils, authGetter func() *auth.Auth, preRun ...func()) (cmd *cobra.Command, err error)

func RegisterRole

func RegisterRole(name, label string)

func RoleUserManager

func RoleUserManager() string

func SetUserAdminMenuEnabled

func SetUserAdminMenuEnabled(res *admin.Resource)

func SetUserPassword

func SetUserPassword(site *core.Site, DB *aorm.DB, Auth *auth.Auth, Notification *notification.Notification,
	user auth.User, passwd string, t ...func(key string, defaul ...interface{}) string) (err error)

func Trigger

func Trigger(d plug.PluginEventDispatcherInterface) *trigger

Types

type AdvancedRoles

type AdvancedRoles map[string]map[string]bool

func (*AdvancedRoles) Add

func (r *AdvancedRoles) Add(group string, name ...string)

func (AdvancedRoles) Has

func (r AdvancedRoles) Has(group string, name ...string) bool

func (AdvancedRoles) Strings

func (r AdvancedRoles) Strings() (names []string)

type AvatarImageStorage

type AvatarImageStorage struct{ oss.OSS }

func (AvatarImageStorage) GetSizes

func (AvatarImageStorage) GetSizes() map[string]*oss.Size

type CliPlugin

type CliPlugin struct {
	plug.EventDispatcher
	SitesRegisterKey,
	AuthKey,
	AdminGetterKey string
	PreRun []func()
}

func (*CliPlugin) OnRegister

func (p *CliPlugin) OnRegister(options *plug.Options)

func (*CliPlugin) RequireOptions

func (p *CliPlugin) RequireOptions() []string

type Config

type Config struct {
	GroupsDisabled       bool
	AccessTokensDisabled bool
}

type Group

type Group struct {
	aorm.AuditedModel
	fragment.FragmentedModel

	Name, Description string

	Users []UserGroup `sql:"foreignkey:GroupID"`
}

type Logouter

type Logouter interface {
	Logout(user interface{}, context *admin.Context)
}

type Logouters

type Logouters []Logouter

func (*Logouters) Append

func (logouters *Logouters) Append(logouter ...Logouter)

type Plugin

type Plugin struct {
	plug.EventDispatcher
	db.DBNames
	admin_plugin.AdminNames

	SitesRegisterKey,
	NotificationKey,
	AuthKey,
	RolesKey,
	LogoutersKey string

	Config Config
}

func (*Plugin) OnRegister

func (p *Plugin) OnRegister(options *plug.Options)

func (*Plugin) RequireOptions

func (p *Plugin) RequireOptions() []string

type RegisterUserEvent

type RegisterUserEvent struct {
	plug.PluginEventInterface
	Site *core.Site
}

type RolesAttribute

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

func (RolesAttribute) AormDefaultDbValue

func (this RolesAttribute) AormDefaultDbValue(dialect aorm.Dialector) string

func (RolesAttribute) GetCollection

func (this RolesAttribute) GetCollection(ctx *admin.Context) (options [][]string)

func (RolesAttribute) Names

func (this RolesAttribute) Names() (names []string)

func (RolesAttribute) Roles

func (this RolesAttribute) Roles(ctx *admin.Context) roles.Roles

func (*RolesAttribute) Scan

func (this *RolesAttribute) Scan(src interface{}) error

func (RolesAttribute) SortedNames

func (this RolesAttribute) SortedNames() (names []string)

func (RolesAttribute) String

func (this RolesAttribute) String(ctx *admin.Context) string

func (RolesAttribute) Strings

func (this RolesAttribute) Strings(ctx *admin.Context) (items []string)

func (*RolesAttribute) StringsScan

func (this *RolesAttribute) StringsScan(src []string) error

func (RolesAttribute) Value

func (this RolesAttribute) Value() (driver.Value, error)

func (RolesAttribute) Values

func (this RolesAttribute) Values(ctx *admin.Context) interface{}

type SetPassword

type SetPassword struct {
	YourPassword    string `admin:"required;type:password"`
	NewPassword     string `admin:"required;type:password"`
	PasswordConfirm string `admin:"required;type:password"`
	// contains filtered or unexported fields
}

func (SetPassword) AdminResourceSetup

func (SetPassword) AdminResourceSetup(res *admin.Resource, defaultSetup func())

type User

type User struct {
	aorm.AuditedSDModel
	fragment.FragmentedModel

	Email string         `form:"email" aorm:"unique;size:64" admin:"required"`
	Name  string         `form:"name" aorm:"unique;size:64" admin:"required"`
	Roles RolesAttribute `aorm:"type:text;default" admin:"select_many;type:select_many"`

	// Confirm
	ConfirmToken string
	Confirmed    bool `aorm:"default"`

	// Recover
	RecoverToken       string `aorm:"size:2048"`
	RecoverTokenExpiry *time.Time

	Super bool `aorm:"default"`

	Location      string        `aorm:"default;size:64"`
	Locale        string        `aorm:"default;size:5"`
	AdvancedRoles AdvancedRoles `sql:"-"`

	AuthAliases  []UserAuthAlias   `aorm:"foreignkey:UserID"`
	AccessTokens []UserAccessToken `aorm:"foreignkey:UserID"`
	// contains filtered or unexported fields
}

func GetUser

func GetUser(DB *aorm.DB, nameOrEmail string) (user *User, err error)

func GetUserAndAuth

func GetUserAndAuth(logMsg string, site *core.Site, nameOrEmail string, authGetter func() *auth.Auth) (user *User, Auth *auth.Auth, err error)

func (*User) AvailableLocales

func (this *User) AvailableLocales() []string

func (*User) BeforeAuth

func (this *User) BeforeAuth(ctx *auth.LoginContext) error

func (*User) DisplayName

func (this *User) DisplayName() string

func (*User) FindUID

func (*User) FindUID(ctx *auth.Context, identifier string) (uid string, err error)

func (*User) GetAormInlinePreloadFields

func (this *User) GetAormInlinePreloadFields() []string

func (*User) GetDefaultLocale

func (this *User) GetDefaultLocale() string

func (*User) GetEmail

func (this *User) GetEmail() string

func (*User) GetLocales

func (this *User) GetLocales() []string

func (*User) GetName

func (this *User) GetName() string

func (*User) GetRoles

func (this *User) GetRoles() (rols roles.Roles)

func (*User) GetTimeLocation

func (this *User) GetTimeLocation() *time.Location

func (*User) GetUID

func (this *User) GetUID() string

func (*User) HasRole

func (this *User) HasRole(name string) (ok bool)

func (*User) IsSuper

func (this *User) IsSuper() bool

func (*User) Schema

func (this *User) Schema() *auth.Schema

func (*User) String

func (this *User) String() string

func (*User) SystemAdmin

func (this *User) SystemAdmin()

func (*User) Validate

func (this *User) Validate(db *aorm.DB)

type UserAccessToken

type UserAccessToken struct {
	aorm.AuditedModel

	UserID            bid.BID `sql:"index"`
	User              *User
	Name, Description string
	ExpireAt          *time.Time
	Enabled           bool
	Token             string
	LimitAccess       uint64
}

type UserAuthAlias

type UserAuthAlias struct {
	aorm.DefinedID
	UserID      bid.BID `sql:"index"`
	User        *User
	Description string
}

type UserGroup

type UserGroup struct {
	aorm.AuditedSDModel

	UserID  bid.BID `sql:"index;unique_index:ux_user_group"`
	User    *User
	GroupID bid.BID `sql:"index;unique_index:ux_user_group"`
	Group   *Group
}

func (UserGroup) GetAormInlinePreloadFields

func (UserGroup) GetAormInlinePreloadFields() []string

type UserRole

type UserRole struct {
	fragment.FormFragmentModel

	Role string
}

func (*UserRole) GetRoles

func (ur *UserRole) GetRoles() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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