port

package module
v1.2.32 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 20 Imported by: 0

README

portsafebackend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func CompareNipp added in v0.0.51

func CompareNipp(MongoConn *mongo.Database, Colname, nipp string) bool

func DecodeGetRole added in v0.0.51

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

func DecodeGetRoleandUser added in v0.0.51

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

func DecodeGetUser added in v0.0.51

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

func DeleteCompromisedAction added in v1.2.5

func DeleteCompromisedAction(mongoconn *mongo.Database, colname, Reportid string) (deletedid interface{}, err error)

func DeleteCompromisedActionData added in v1.2.5

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

func DeleteDataReport added in v1.2.3

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

func DeleteDataUser added in v1.2.31

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

func DeleteReportData added in v0.0.56

func DeleteReportData(mongoconn *mongo.Database, colname, Reportid string) (deletedid interface{}, err error)

func DeleteUser added in v0.0.38

func DeleteUser(mongoconn *mongo.Database, colname, Nipp string) (deletedid interface{}, err error)

func EncodeWithRole added in v0.0.51

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

func FollowUpCompromisedAction added in v1.2.5

func FollowUpCompromisedAction(Publickey, MongoEnv, dbname, colname string, r *http.Request) string

func GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

func GetAllCompromisedActions added in v1.2.5

func GetAllCompromisedActions(PublicKey, Mongoenv, dbname, colname string, r *http.Request) string

func GetAllCompromisedActionsByUser added in v1.2.5

func GetAllCompromisedActionsByUser(PublicKey, Mongoenv, dbname, colname string, r *http.Request) string

func GetAllReport added in v0.0.56

func GetAllReport(PublicKey, Mongoenv, dbname, colname string, r *http.Request) string

func GetAllReportByNipp added in v1.1.18

func GetAllReportByNipp(PublicKey, Mongoenv, dbname, colname string, r *http.Request) string

func GetAllUserData added in v1.2.3

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

func GetDataUser added in v1.1.6

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

func GetOneCompromisedAction added in v1.2.5

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

CRUD Compromised Action

func GetOneReport added in v0.0.56

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

CRUD Unsafe Action

func HashPassword

func HashPassword(password string) (string, error)

func InsertCompromisedAction added in v1.2.5

func InsertCompromisedAction(Publickey, MongoEnv, dbname, colname string, r *http.Request) string

func InsertOneDoc added in v0.0.51

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

func InsertReportAction added in v1.2.5

func InsertReportAction(MongoConn *mongo.Database, colname string, rpt ReportUnsafeAction) (InsertedID interface{})

func InsertReportCompromised added in v1.2.5

func InsertReportCompromised(MongoConn *mongo.Database, colname string, rpt ReportCompromisedAction) (InsertedID interface{})

func InsertReportUnsafeAction added in v1.2.5

func InsertReportUnsafeAction(Publickey, MongoEnv, dbname, colname string, r *http.Request) string

func InsertUserdata added in v0.0.51

func InsertUserdata(MongoConn *mongo.Database, nipp, nama, jabatan, location, password, role string) (InsertedID interface{})

func IsAdmin added in v0.0.51

func IsAdmin(Tokenstr, PublicKey string) bool

func IsUser added in v0.0.51

func IsUser(TokenStr, Publickey string) bool

func Login added in v0.0.51

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

func PasswordValidator added in v0.0.51

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

func Register added in v0.0.51

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

Authorization

func S3Client added in v1.1.43

func S3Client(c Config) (*s3.Client, error)

S3Client mengembalikan klien S3 baru untuk konfigurasi R2 yang diberikan.

func SaveUploadedFile added in v1.1.36

func SaveUploadedFile(file *multipart.FileHeader, bucketName string, s3Client *s3.Client) (string, error)

SaveUploadedFile menyimpan file ke R2 menggunakan metode tertentu

func SetConnection

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

func TokenEncoder added in v0.0.51

func TokenEncoder(username, privatekey string) string

func UpdateReportAction added in v1.2.5

func UpdateReportAction(Mongoconn *mongo.Database, ctx context.Context, rpt ReportUnsafeAction) (UpdateId interface{}, err error)

func UpdateReportCompromised added in v1.2.5

func UpdateReportCompromised(Mongoconn *mongo.Database, ctx context.Context, colname string, rpt ReportCompromisedAction) (UpdateId interface{}, err error)

func UpdateReportUnsafeAction added in v1.2.5

func UpdateReportUnsafeAction(Publickey, MongoEnv, dbname, colname string, r *http.Request) string

func UpdateUser added in v1.2.16

func UpdateUser(mongoconn *mongo.Database, user User) (Updatedid interface{})

func UpdateUserAdmin added in v1.2.23

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

func UploadFileHandler added in v1.1.36

func UploadFileHandler(w http.ResponseWriter, r *http.Request)

UploadFileHandler menangani permintaan pengunggahan file

Types

type Area added in v0.0.53

type Area struct {
	AreaId   string `json:"areaId" bson:"areaId"`
	AreaName string `json:"areaName" bson:"areaName"`
}

func GetAreaByName added in v0.1.1

func GetAreaByName(MongoConn *mongo.Database, areaName string) *Area

CRUD Unsafe Action

type Config added in v1.1.43

type Config struct {
	AccountID       string
	AccessKeyID     string
	SecretAccessKey string
}

type Cred added in v0.0.51

type Cred struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

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"`
	Role    string `json:"role,omitempty" bson:"role,omitempty"`
}

type Location added in v0.0.58

type Location struct {
	LocationId   string `json:"locationId" bson:"locationId"`
	LocationName string `json:"locationName" bson:"locationName"`
}

func GetLocationByName added in v0.1.1

func GetLocationByName(MongoConn *mongo.Database, locationName string) *Location

type Payload added in v0.0.38

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

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

type ReportCompromisedAction added in v1.2.5

type ReportCompromisedAction struct {
	Reportid             string                 `json:"reportid"`
	Date                 string                 `json:"date"`
	Time                 string                 `json:"time" bson:"time"`
	User                 User                   `json:"user"`
	Location             Location               `json:"location"`
	Area                 Area                   `json:"area"`
	Description          string                 `json:"description"`
	ObservationPhoto     string                 `json:"observationPhoto"`
	TypeDangerousActions []TypeDangerousActions `json:"typeDangerousActions" bson:"typeDangerousActions,omitempty"`
	ImmediateAction      string                 `json:"immediateAction" bson:"immediateAction"`
	ImprovementPhoto     string                 `json:"improvementPhoto" bson:"improvementPhoto"`
	Recomendation        string                 `json:"recomendation"`
	ActionDesc           string                 `json:"ActionDesc"`
	EvidencePhoto        string                 `json:"EvidencePhoto"`
	Status               string                 `json:"status"`
}

func GetAllCompromisedActionData added in v1.2.5

func GetAllCompromisedActionData(Mongoconn *mongo.Database, colname string) []ReportCompromisedAction

func GetAllCompromisedActionDataByUser added in v1.2.5

func GetAllCompromisedActionDataByUser(conn *mongo.Database, colname, nipp string) ([]ReportCompromisedAction, error)

func GetOneCompromisedActionData added in v1.2.5

func GetOneCompromisedActionData(mongoconn *mongo.Database, colname, Reportid string) (dest ReportCompromisedAction)

CRUD Compromised Action

func GetReportCompromisedByID added in v1.2.5

func GetReportCompromisedByID(MongoConn *mongo.Database, reportID string) *ReportCompromisedAction

type ReportUnsafeAction added in v1.2.5

type ReportUnsafeAction struct {
	Reportid             string                 `json:"reportid" bson:"reportid"`
	Date                 string                 `json:"date" bson:"date"`
	Time                 string                 `json:"time" bson:"time"`
	User                 User                   `json:"user" bson:"user,omitempty"`
	Location             Location               `json:"location" bson:"location"`
	Description          string                 `json:"description" bson:"description"`
	ObservationPhoto     string                 `json:"observationPhoto" bson:"observationPhoto"`
	TypeDangerousActions []TypeDangerousActions `json:"typeDangerousActions" bson:"typeDangerousActions,omitempty"`
	Area                 Area                   `json:"area" bson:"area"`
	ImmediateAction      string                 `json:"immediateAction" bson:"immediateAction"`
	ImprovementPhoto     string                 `json:"improvementPhoto" bson:"improvementPhoto"`
}

func GetAllReportData added in v0.0.56

func GetAllReportData(Mongoconn *mongo.Database, colname string) []ReportUnsafeAction

func GetAllReportDataByUser added in v1.1.13

func GetAllReportDataByUser(conn *mongo.Database, colname, nipp string) ([]ReportUnsafeAction, error)

func GetOneReportData added in v0.0.56

func GetOneReportData(mongoconn *mongo.Database, colname, Reportid string) (dest ReportUnsafeAction)

type ReqUsers added in v0.0.51

type ReqUsers struct {
	Nipp string `json:"nipp"`
}

type RequestReport added in v0.0.53

type RequestReport struct {
	Reportid string `json:"reportid"`
}

type RequestReportCompromisedAction added in v1.2.5

type RequestReportCompromisedAction struct {
	Reportid string `json:"reportid"`
}

type Response added in v0.0.38

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

type ResponseBack added in v0.0.53

type ResponseBack struct {
	Status  int      `json:"status"`
	Message string   `json:"message"`
	Data    []string `json:"data"`
}

type ResponseDataUser added in v0.0.51

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

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

type ResponseReport added in v0.0.53

type ResponseReport struct {
	Status  int                `json:"status"`
	Message string             `json:"message"`
	Data    ReportUnsafeAction `json:"data"`
}

type ResponseReportBanyak added in v0.0.53

type ResponseReportBanyak struct {
	Status  int                  `json:"status"`
	Message string               `json:"message"`
	Data    []ReportUnsafeAction `json:"data"`
}

type ResponseReportCompromisedAction added in v1.2.5

type ResponseReportCompromisedAction struct {
	Status  int                     `json:"status"`
	Message string                  `json:"message"`
	Data    ReportCompromisedAction `json:"data"`
}

type ResponseReportCompromisedActionBanyak added in v1.2.5

type ResponseReportCompromisedActionBanyak struct {
	Status  int                       `json:"status"`
	Message string                    `json:"message"`
	Data    []ReportCompromisedAction `json:"data"`
}

type TypeDangerousActions added in v0.0.53

type TypeDangerousActions struct {
	TypeId   string   `json:"typeId" bson:"typeId"`
	TypeName string   `json:"typeName" bson:"typeName"`
	SubTypes []string `json:"subTypes" bson:"subTypes"`
}

type User

type User struct {
	Nipp      string    `json:"nipp" bson:"nipp"`
	Nama      string    `json:"nama" bson:"nama"`
	Jabatan   string    `json:"jabatan" bson:"jabatan"`
	Location  Location  `json:"location"`
	Password  string    `json:"password" bson:"password"`
	Role      string    `json:"role,omitempty" bson:"role,omitempty"`
	Timestamp time.Time `json:"timestamp" bson:"timestamp"`
}

func GetAllUser added in v0.0.51

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

CRUD User

func GetOneUser added in v0.0.51

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

func GetUserByNipp added in v0.1.1

func GetUserByNipp(MongoConn *mongo.Database, nipp string) (*User, error)

Jump to

Keyboard shortcuts

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