identity

package
v0.0.0-...-175e951 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUserToGroup

func AddUserToGroup(groupKey, userEmail string, dbConf *db.DBConfigDef) error

func CheckPasswordByUserId

func CheckPasswordByUserId(userId, password string, identityRepo IdentityRepo) bool

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GetCurrentOrganizationUser

func GetCurrentOrganizationUser(cu ContextUserManager, c context.Context) *dm.OrganizationUser

func HashPassword

func HashPassword(password string) (string, error)

func ResetPassword

func ResetPassword(
	identityRepo IdentityRepo,
	secretKey string,
	message string,
	newPassword string,
) error

func SendResetPasswordEmail

func SendResetPasswordEmail(
	emailBackend email.EmailBackend,
	secretKey string,
	user *dm.User,
	identityRepo IdentityRepo,
	baseURL *url.URL,
) error

Types

type AuthenticatedUser

type AuthenticatedUser struct {
	User *dm.User
}

type AuthenticationInfo

type AuthenticationInfo struct {
	AuthenticatedUser *AuthenticatedUser
	AuthorizedUser    *AuthorizedUser
}

type AuthorizedUser

type AuthorizedUser struct {
	OrganizationUser *dm.OrganizationUser
}

type ContextUserManager

type ContextUserManager interface {
	// GetAuthenticationInfo returns the authentication info from the given context.
	GetAuthenticationInfo(c context.Context) *AuthenticationInfo
	// WithAuthenticationInfo returns a new context with the given authentication info.
	WithAuthenticationInfo(c context.Context, authenticationInfo *AuthenticationInfo) context.Context
	// SetAuthenticationInfo sets the given authentication info to the given context.
	SetAuthenticationInfo(c context.Context, authenticationInfo *AuthenticationInfo)
}

type DBIdentityRepo

type DBIdentityRepo struct {
	db.RepoConn
}

func NewDBIdentityRepo

func NewDBIdentityRepo(conn *sql.DB) *DBIdentityRepo

func (*DBIdentityRepo) AddRoleToOrganizationUser

func (repo *DBIdentityRepo) AddRoleToOrganizationUser(organizationUserId, roleKey string) error

func (*DBIdentityRepo) CreateOrganization

func (repo *DBIdentityRepo) CreateOrganization(name, slug string) (*dm.Organization, error)

func (*DBIdentityRepo) CreateUser

func (repo *DBIdentityRepo) CreateUser(email string, password string) (*dm.User, error)

func (*DBIdentityRepo) CreateUserWithOrganization

func (repo *DBIdentityRepo) CreateUserWithOrganization(
	email string, organizationName string, password string,
) (*dm.OrganizationUser, error)

func (*DBIdentityRepo) GetAllUsers

func (repo *DBIdentityRepo) GetAllUsers(limit int, offset int, search *string) ([]*dm.User, int)

func (*DBIdentityRepo) GetOrganizationById

func (repo *DBIdentityRepo) GetOrganizationById(id string) *dm.Organization

func (*DBIdentityRepo) GetOrganizationForUser

func (repo *DBIdentityRepo) GetOrganizationForUser(userId string, maybeOrganizationId string) (*dm.Organization, *dm.OrganizationUser)

func (*DBIdentityRepo) GetOrganizationUserById

func (repo *DBIdentityRepo) GetOrganizationUserById(id string) *dm.OrganizationUser

func (*DBIdentityRepo) GetOrganizationUsersByIds

func (repo *DBIdentityRepo) GetOrganizationUsersByIds(ids []string) []*dm.OrganizationUser

func (*DBIdentityRepo) GetOrganizationUsersForUsers

func (repo *DBIdentityRepo) GetOrganizationUsersForUsers(userIds []string) (
	userIdToOrgUser map[string]*dm.UserWithOrganizationUsers,
	err error,
)

func (*DBIdentityRepo) GetOrganizationsByIds

func (repo *DBIdentityRepo) GetOrganizationsByIds(ids []string) []*dm.Organization

func (*DBIdentityRepo) GetUserByEmail

func (repo *DBIdentityRepo) GetUserByEmail(email string) *dm.User

func (*DBIdentityRepo) GetUserById

func (repo *DBIdentityRepo) GetUserById(id string) *dm.User

func (*DBIdentityRepo) GetUserPassword

func (repo *DBIdentityRepo) GetUserPassword(id string) string

func (*DBIdentityRepo) GetUsersByIds

func (repo *DBIdentityRepo) GetUsersByIds(ids []string) []*dm.User

func (*DBIdentityRepo) UpdateUserPassword

func (repo *DBIdentityRepo) UpdateUserPassword(id string, password string) error

func (*DBIdentityRepo) WithTransaction

func (repo *DBIdentityRepo) WithTransaction(tx *sql.Tx) db.DBRepo

type IdentityRepo

type IdentityRepo interface {
	CreateUserWithOrganization(email string, organizationName string, password string) (*dm.OrganizationUser, error)
	CreateUser(email string, password string) (*dm.User, error)
	AddRoleToOrganizationUser(organizationUserId string, roleKey string) error

	GetUserById(id string) *dm.User
	GetUsersByIds(ids []string) []*dm.User
	GetUserByEmail(email string) *dm.User

	// If maybeOrganizationId is not empty, it will be used as the organization ID.
	// Otherwise, the implementation should guess the best organization ID for the user.
	// E.g. if the user is a member of only one organization, that organization ID should be used.
	// If the user is a member of multiple organizations, the implementation should return nil.
	GetOrganizationForUser(userId string, maybeOrganizationId string) (*dm.Organization, *dm.OrganizationUser)

	GetOrganizationUsersForUsers(userIds []string) (map[string]*dm.UserWithOrganizationUsers, error)

	GetOrganizationUsersByIds(ids []string) []*dm.OrganizationUser
	GetOrganizationUserById(id string) *dm.OrganizationUser

	GetUserPassword(id string) string
	UpdateUserPassword(id string, password string) error

	// GetAllUsers returns a paginated list of users with optional search criteria.
	GetAllUsers(limit int, offset int, search *string) ([]*dm.User, int)
}

Jump to

Keyboard shortcuts

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