auth

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 13 Imported by: 0

README

authbackend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func CompareHashPass

func CompareHashPass(password, hash string) bool

func CompareNipp

func CompareNipp(MongoConn *mongo.Database, Colname, nipp 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 GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

func HashPassword

func HashPassword(password string) (string, error)

func InsertOneDoc

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

func InsertUserdata

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

func PasswordValidator

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

func Register

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

func SetConnection

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

func TokenEncoder

func TokenEncoder(username, privatekey string) string

Types

type Cred

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

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 Properties

type Properties struct {
	Name string `json:"name" bson:"name"`
}

type Report

type Report struct {
	ID                 primitive.ObjectID `bson:"_id,omitempty" `
	Reportid           string             `json:"reportid" bson:"reportid"`
	Date               string             `json:"date" bson:"date"`
	Supervisorid       int                `json:"supervisorid" bson:"supervisorid"`
	SupervisorName     string             `json:"supervisorname" bson:"supervisorname"`
	SupervisorPosition string             `json:"supervisorposition" bson:"supervisorposition"`
	IncidentLocation   string             `json:"incidentlocation" bson:"incidentlocation"`
	Description        string             `json:"description" bson:"description"`
	ObservationPhoto   string             `json:"observationphoto" bson:"observationphoto"`
	PeopleReactions    string             `json:"peoplereactions" bson:"peoplereactions"`
	PPE                string             `json:"ppe" bson:"ppe"`
	PersonPosition     string             `json:"personposition" bson:"personposition"`
	Equipment          string             `json:"equipment" bson:"equipment"`
	WorkProcedure      string             `json:"workprocedure" bson:"workprocedure"`
	Area               string             `json:"area" bson:"area"`
	ImmediateAction    string             `json:"immediateaction" bson:"immediateaction"`
	ImprovementPhoto   string             `json:"improvementphoto" bson:"improvementphoto"`
	CorrectiveAction   string             `json:"correctiveaction" bson:"correctiveaction"`
}

type ReqUsers

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

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 {
	Nipp     string `json:"nipp" bson:"nipp"`
	Nama     string `json:"nama" bson:"nama"`
	Jabatan  string `json:"jabatan" bson:"jabatan"`
	Divisi   string `json:"divisi" bson:"divisi"`
	Bidang   string `json:"bidang" bson:"bidang"`
	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