backenduser

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 13 Imported by: 0

README

backenduser

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHashPass

func CompareHashPass(password, hash string) bool

func CreateNewReport

func CreateNewReport(mongoconn *mongo.Database, collection string, reportdata Report) interface{}

Report

func CreateNewUserRole

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

User

func CreateReport

func CreateReport(mongoconn *mongo.Database, collection string, reportdata Report) interface{}

Report function

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

user

func DeleteOneDoc

func DeleteOneDoc(_id primitive.ObjectID, db *mongo.Database, col string) error

func DeleteReport

func DeleteReport(mongoconn *mongo.Database, collection string, reportdata Report) interface{}

func DeleteUser

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

func GCFDeleteReport

func GCFDeleteReport(publickey, MONGOCONNSTRINGENV, dbname, colluser, collreport string, r *http.Request) string

delete report

func GCFGetAllReport

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

get all report

func GCFGetAllReportID

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

get all report by id

func GCFInsertReport

func GCFInsertReport(publickey, MONGOCONNSTRINGENV, dbname, colluser, collreport string, r *http.Request) string

Insert Report post

func GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

return struct

func GetAllDocs

func GetAllDocs(db *mongo.Database, col string, docs interface{}) interface{}

crud

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 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 & Register User --->

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

func UpdateOneDoc

func UpdateOneDoc(id primitive.ObjectID, db *mongo.Database, col string, doc interface{}) (err error)

func UpdatedReport

func UpdatedReport(mongoconn *mongo.Database, collection string, filter bson.M, reportdata Report) interface{}

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 {
	Id     primitive.ObjectID `json:"id"`
	User   string             `json:"user"`
	Report string             `json:"report"`
	Role   string             `json:"role"`
	Exp    time.Time          `json:"exp"`
	Iat    time.Time          `json:"iat"`
	Nbf    time.Time          `json:"nbf"`
}

func IsTokenValid

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

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

type Report

type Report struct {
	ID           primitive.ObjectID `bson:"_id,omitempty" `
	Nik          int                `json:"nik" bson:"nik"`
	Title        string             `json:"title"`
	Description  string             `json:"description"`
	DateOccurred string             `json:"dateOccurred"`
	Image        string             `json:"image" bson:"image"`
	Status       bool               `json:"status" bson:"status"`
}

func GetAllReport

func GetAllReport(mongoconn *mongo.Database, collection string) []Report

func GetAllReportID

func GetAllReportID(mongoconn *mongo.Database, collection string, reportdata Report) Report

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 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"`
	Token    string `json:"token,omitempty" bson:"token,omitempty"`
	Private  string `json:"private,omitempty" bson:"private,omitempty"`
	Public   string `json:"public,omitempty" bson:"public,omitempty"`
}

func FindUser

func FindUser(mongoconn *mongo.Database, collection string, userdata User) 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