yabi

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 7 Imported by: 0

README

yabi The yabi package is a complete user's authentication system for your next Go's project, from user's registration, password reset, login, logout, timaan token, and automatic email notifications and many more. Currently supported database is MongoDB, in the future, there will be more supported databases.

Installation

go get -u github.com/itrepablik/yabi

Usage

This is the sample usage for the sulat package.


License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

Documentation

Index

Constants

View Source
const CollUserMG = _initName + "user"

CollUserMG is the exact MongoDB collection name for the user's collection.

Variables

This section is empty.

Functions

func CreateUserMG

func CreateUserMG(userName, password, email string, isSuperUser, isAdminUser bool) (bool, error)

CreateUserMG creates a new user registration using MongoDB.

func NewTimaanToken

func NewTimaanToken(payLoad timaan.TP, expireOn int64) (string, error)

NewTimaanToken creates a new timaan token and returns with a new token the 'expireOn' int64 must use the unix time e.g time.Now().Add(time.Minute * 30).Unix()

func UseClientMG

func UseClientMG()

UseClientMG set the clientMG variable globally

Types

type Config

type Config struct {
	TimeZone string
	// contains filtered or unexported fields
}

Config list of common config variables

var CF *Config

CF short hand for 'Config' struct

func SetConfig

func SetConfig(c *Config) *Config

SetConfig set the yabi common config variables

type MGCon

type MGCon struct {
	ConStr, DBName, CollName, TimeZone string
	ClientMG                           *itrmg.MGC
	// contains filtered or unexported fields
}

MGCon collects the MongoDB connection information

func InitMGCon

func InitMGCon(conStr, dbName, collName, tz string) *MGCon

InitMGCon initializes the MongoDB

func SetMGCon

func SetMGCon(conStr, dbName, collName, tz string) (*MGCon, error)

SetMGCon set your custom MongoDB connection strings here

type UserMG

type UserMG struct {
	ID          itrmg.ObjID `json:"_id,omitempty" bson:"_id,omitempty"`
	UserName    string      `json:"username,omitempty" bson:"username,omitempty"`
	Password    string      `json:"password" bson:"password,omitempty"`
	Email       string      `json:"email,omitempty" bson:"email,omitempty"`
	FirstName   string      `json:"first_name,omitempty" bson:"first_name,omitempty"`
	MiddleName  string      `json:"middle_name,omitempty" bson:"middle_name,omitempty"`
	LastName    string      `json:"last_name,omitempty" bson:"last_name,omitempty"`
	Suffix      string      `json:"suffix,omitempty" bson:"suffix,omitempty"`
	Gender      string      `json:"gender,omitempty" bson:"gender,omitempty"`
	DOB         int64       `json:"dob,omitempty" bson:"dob,omitempty"`
	About       string      `json:"about,omitempty" bson:"about,omitempty"`
	URL         string      `json:"url,omitempty" bson:"url,omitempty"`
	IsSuperUser bool        `json:"is_superuser,omitempty" bson:"is_superuser,omitempty"`
	IsAdmin     bool        `json:"is_admin,omitempty" bson:"is_admin,omitempty"`
	LastLogin   int64       `json:"last_login,omitempty" bson:"last_login,omitempty"`
	DateJoined  int64       `json:"date_joined,omitempty" bson:"date_joined,omitempty"`
	IsActive    bool        `json:"is_active,omitempty" bson:"is_active,omitempty"`
}

UserMG is a MongoDB user model

Jump to

Keyboard shortcuts

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