laundrybackend

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 13 Imported by: 0

README

laundrybackend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(passwordhash, hash string) bool

func CreateAdmin

func CreateAdmin(mongoconn *mongo.Database, collection string, admindata Admin) interface{}

func CreateNewUserRole

func CreateNewUserRole(mongoconn *mongo.Database, collection string, userdata User) interface{}

Function User

func CreateUser

func CreateUser(mongoconn *mongo.Database, collection string, userdata User) interface{}

func CreateUserAndAddToken

func CreateUserAndAddToken(privateKeyEnv string, mongoconn *mongo.Database, collection string, userdata User) error

func GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

func HashPass

func HashPass(passwordhash string) (string, error)

func InsertOneDoc

func InsertOneDoc(db *mongo.Database, collection string, doc interface{}) (insertedID interface{})

func InsertUserdata

func InsertUserdata(MongoConn *mongo.Database, usernameid, username, nohp, password, passwordhash, email, role string) (InsertedID interface{})

Function User

func IsPasswordValidEmail

func IsPasswordValidEmail(mongoconn *mongo.Database, collection string, userdata User) bool

func IsPasswordValidEmailAdmin

func IsPasswordValidEmailAdmin(mongoconn *mongo.Database, collection string, admindata Admin) bool

Function Admin

func IsPasswordValidNPM

func IsPasswordValidNPM(mongoconn *mongo.Database, collection string, userdata User) bool

func LoginAdmin

func LoginAdmin(PASETOPRIVATEKEYENV, MONGOCONNSTRINGENV, dbname, collectionname string, r *http.Request) string

Function Admin

func LoginUser

func LoginUser(PASETOPRIVATEKEYENV, MONGOCONNSTRINGENV, dbname, collectionname string, r *http.Request) string

func MongoCreateConnection

func MongoCreateConnection(MongoString, dbname string) *mongo.Database

func Register

func Register(Mongoenv, dbname string, r *http.Request) string

Function User

func ReturnStringStruct

func ReturnStringStruct(Data any) string

func SetConnection

func SetConnection(MONGOCONNSTRINGENV, dbname string) *mongo.Database

Types

type Admin

type Admin struct {
	UsernameId   string `json:"usernameid" bson:"usernameid"`
	Username     string `json:"username" bson:"username"`
	Password     string `json:"password" bson:"password"`
	PasswordHash string `json:"passwordhash" bson:"passwordhash"`
	Email        string `bson:"email,omitempty" json:"email,omitempty"`
	Role         string `json:"role,omitempty" bson:"role,omitempty"`
	Token        string `json:"token,omitempty" bson:"token,omitempty"`
	Private      string `json:"private,omitempty" bson:"private,omitempty"`
	Public       string `json:"public,omitempty" bson:"public,omitempty"`
}

type Credential

type Credential struct {
	Status  bool   `json:"status" bson:"status"`
	Token   string `json:"token,omitempty" bson:"token,omitempty"`
	Message string `json:"message,omitempty" bson:"message,omitempty"`
}

type EmailValidator

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

func NewEmailValidator

func NewEmailValidator() *EmailValidator

func (*EmailValidator) IsValid

func (v *EmailValidator) IsValid(email string) bool

IsValid memeriksa apakah email sesuai dengan pola npm@std.ulbi.ac.id

type Payload

type Payload struct {
	User string    `json:"user"`
	Role string    `json:"role"`
	Exp  time.Time `json:"exp"`
	Iat  time.Time `json:"iat"`
	Nbf  time.Time `json:"nbf"`
}

type Response

type Response struct {
	Status  bool        `json:"status" bson:"status"`
	Message string      `json:"message" bson:"message"`
	Data    interface{} `json:"data" bson:"data"`
}

type User

type User struct {
	ID           primitive.ObjectID `bson:"_id,omitempty" `
	UsernameId   string             `json:"usernameid" bson:"usernameid"`
	Username     string             `json:"username" bson:"username"`
	Nohp         string             `json:"nohp" bson:"nohp"`
	Password     string             `json:"password" bson:"password"`
	PasswordHash string             `json:"passwordhash" bson:"passwordhash"`
	Email        string             `bson:"email,omitempty" json:"email,omitempty"`
	Role         string             `json:"role,omitempty" bson:"role,omitempty"`
	Token        string             `json:"token,omitempty" bson:"token,omitempty"`
	Private      string             `json:"private,omitempty" bson:"private,omitempty"`
	Public       string             `json:"public,omitempty" bson:"public,omitempty"`
}

Jump to

Keyboard shortcuts

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