models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserModel *mapi.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"`
}

func CreateUserWithNewOrg

func CreateUserWithNewOrg(orgName string, fullname string, email string, pwd string) (*AuthInfo, []mapi.ApiError)

CreateUserWithNewOrg will create new user with new organization

func SignIn

func SignIn(email string, pwd string) (*AuthInfo, []mapi.ApiError)

SignIn will create a JWT token

type Role

type Role string
const (
	Admin  Role = "ADMIN"
	Tenant Role = "TENANT"
	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"`
}

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"`
}

func GetUserByUserId

func GetUserByUserId(userId primitive.ObjectID) (*UserFields, *mapi.ApiError)

func NewUserWithId

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

Jump to

Keyboard shortcuts

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