webpasetobackend

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashPass

func CompareHashPass(password, hash string) bool

func CompareUsername

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

func DecodeGetRole

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

func DecodeGetRoleandUser

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

func DecodeGetUser

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

func EncodeWithRole

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

func GCFPasetoTokenStr

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

func HashPass

func HashPass(password string) (string, error)

func HashPasswordGCF

func HashPasswordGCF(r *http.Request) string

func InsertOneDoc

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

func InsertReportData added in v0.0.3

func InsertReportData(conn *mongo.Database, colname string, report *Report) error

func InsertUserdata

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

func MasukkanDataUserGCF

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

func MongoCreateConnection

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

func PasswordValidator

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

func RetrieveDataUserGCF

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

func ReturnStringStruct

func ReturnStringStruct(Data any) string

func TokenEncoder

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

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

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

type Report added in v0.0.3

type Report struct {
	Title          string `json:"title"`
	Description    string `json:"description"`
	DateOccurred   string `json:"dateOccurred"`
	FileAttachment string `json:"fileAttachment"`
}

type Response

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

type ResponseDataUser

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

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

func GetAllUser

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

func GetOneUser

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