Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var UserModel *mapi.Model
UserModel stores user model
Functions ¶
func RegisterUserModel ¶
func RegisterUserModel()
RegisterUserModel will allow the ability for a system to use the UserModel
Types ¶
type AuthInfo ¶
type AuthInfo struct { Token string `json:"token,omitempty"` Fullname string `json:"fullname,omitempty"` }
AuthInfo holds information about an authenticated user
type Role ¶
type Role string
Role is an enum that describes role in the system
const ( // Admin is a role that describes users that have // full access to the entire system Admin Role = "ADMIN" // Tenant is a role that describes users that own // an organization Tenant Role = "TENANT" // User is a role that describes users that is a // part of an organization User Role = "USER" )
type RoleFields ¶
type RoleFields struct { OrgName string `bson:"orgName,omitempty"` Role Role `bson:"role" validate:"required"` Description string `bson:"description,omitempty"` TenantID primitive.ObjectID `bson:"tenantId" validate:"required"` }
RoleFields holds the role a user has to an organization
type UserFields ¶
type UserFields struct { ID primitive.ObjectID `bson:"_id" json:"_id"` FullName string `bson:"fullName" json:"fullName" validate:"required"` Email string `bson:"email" json:"email" validate:"required,email"` Password string `bson:"password" json:"password"` EmailConfirmed bool `bson:"emailConfirmed,omitempty" json:"emailConfirmed,omitempty"` ConfirmationToken string `bson:"confirmationToken,omitempty" json:"confirmationToken,omitempty"` Roles []RoleFields `bson:"roles,omitempty" json:"roles,omitempty" validate:"required"` }
UserFields hold information about a user
func GetUserByUserID ¶ added in v0.0.3
func GetUserByUserID(userID primitive.ObjectID) (*UserFields, *mapi.APIError)
GetUserByUserID gets a user from db
func NewUserWithID ¶ added in v0.0.3
func NewUserWithID(id primitive.ObjectID, fullName string, email string, plainPwd string, emailConfirmed bool, roles []RoleFields) (UserFields, error)
NewUserWithID creates a new user, encrypts password and depending on email setting
it will create an emailConfirmation token
Click to show internal directories.
Click to hide internal directories.