petback

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 12 Imported by: 2

README

petback

pembuatan package go untuk tugas GIS chapter 01-akhir

go get -u all
go mod tidy
git tag                                 #check current version
git tag v0.0.28                          #set tag version
git push origin --tags                  #push tag version to repo
go list -m github.com/nugisorange/petback@version   #example v0.0.1 #publish to pkg dev, replace ORG/URL with your repo URL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashPass added in v0.0.5

func CompareHashPass(password, hash string) bool

func CompareUsername added in v0.0.5

func CompareUsername(MongoConn *mongo.Database, Colname, username string) bool

func DecodeGetRole added in v0.0.5

func DecodeGetRole(PublicKey, tokenStr string) (pay string, err error)

func DecodeGetRoleandUser added in v0.0.5

func DecodeGetRoleandUser(PublicKey, tokenStr string) (pay string, use string)

func DecodeGetUser added in v0.0.5

func DecodeGetUser(PublicKey, tokenStr string) (pay string, err error)

func EncodeWithRole added in v0.0.5

func EncodeWithRole(role, username, privatekey string) (string, error)

func GCFPasetoTokenStr added in v0.0.5

func GCFPasetoTokenStr(PrivateKey, MongoEnv, dbname, collectionname string, r *http.Request) string

<---Function untuk token--->

func GCFPasswordHasher added in v0.0.5

func GCFPasswordHasher(r *http.Request) string

func GetDataUserFromGCF added in v0.0.5

func GetDataUserFromGCF(PublicKey, MongoEnv, dbname, colname string, r *http.Request) string

<---Function untuk ambil data lewat gcf--->

func HashPass added in v0.0.5

func HashPass(password string) (string, error)

func InsertDataUserGCF added in v0.0.5

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

func InsertOneDoc added in v0.0.5

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

func InsertUserdata added in v0.0.5

func InsertUserdata(MongoConn *mongo.Database, val User) (InsertedID interface{})

func MongoCreateConnection added in v0.0.5

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

func PasswordValidator added in v0.0.5

func PasswordValidator(MongoConn *mongo.Database, colname string, userdata User) bool

func ReturnStringStruct added in v0.0.3

func ReturnStringStruct(Data any) string

func TokenEncoder added in v0.0.5

func TokenEncoder(username, privatekey string) string

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 added in v0.0.5

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

func Decoder added in v0.0.5

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

type Response added in v0.0.5

type Response struct {
	Token string `json:"token,omitempty" bson:"token,omitempty"`
}

type ResponseDataUser added in v0.0.5

type ResponseDataUser struct {
	Status  bool   `json:"status" bson:"status"`
	Message string `json:"message,omitempty" bson:"message,omitempty"`
	Data    []User `json:"data,omitempty" bson:"data,omitempty"`
}

type ResponseEncode added in v0.0.5

type ResponseEncode struct {
	Message string `json:"message,omitempty" bson:"message,omitempty"`
	Token   string `json:"token,omitempty" bson:"token,omitempty"`
}

type User

type User struct {
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
	Role     string `json:"role,omitempty" bson:"role,omitempty"`
	PhoneNum string `json:"phoneNum" bson:"phoneNum"`
}

func GetAllUser added in v0.0.5

func GetAllUser(MongoConn *mongo.Database, colname string) []User

func GetOneUser added in v0.0.5

func GetOneUser(MongoConn *mongo.Database, colname string, userdata User) User

Jump to

Keyboard shortcuts

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