lapak

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 12 Imported by: 0

README

User-Lapak-UMK

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func CompareHashPass

func CompareHashPass(password, hash string) bool

func CreateNewUserRole

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

user

func CreateUser

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

user

func CreateUserAndAddToken

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

user

func GCFReturnStruct

func GCFReturnStruct(DataStruct any) string

return struct

func HashPass

func HashPass(password string) (string, error)

func InsertOneDoc

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

func InsertUserdata

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

func IsExist

func IsExist(Tokenstr, PublicKey string) bool

func IsPasswordValid

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

func Login

func Login(Privatekey, MongoEnv, dbname, Colname string, r *http.Request) string

<--- ini Login Email & Register Email --->

func MongoCreateConnection

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

func Register

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

func ReturnStringStruct

func ReturnStringStruct(Data any) string

func SetConnection

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

Types

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 Payload

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

func Decoder

func Decoder(publickey, tokenstr string) (payload Payload, err error)

<--- paseto encoder ---> memeriksa token

type RegisterStruct

type RegisterStruct struct {
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
}

type Response

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

func CreateResponse

func CreateResponse(status bool, message string, data interface{}) Response

type User

type User struct {
	Username     string `json:"username" bson:"username"`
	Password     string `json:"password" bson:"password"`
	PasswordHash string `json:"passwordhash" bson:"passwordhash"`
	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