pasetobackend

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 12 Imported by: 1

README

pasetobackend

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 GCFPasswordHasher

func GCFPasswordHasher(r *http.Request) string

func GetDataUserFromGCF

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

func HashPass

func HashPass(password string) (string, error)

func InsertDataUserGCF

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

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 MongoCreateConnection

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

func PasswordValidator

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

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 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