pasetobackend

package module
v0.2.7 Latest Latest
Warning

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

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

README

pasetobackend

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEmail added in v0.1.4

func CheckEmail(email string) bool

check email @std.ulbi.ac.id

func CheckPasswordHash added in v0.0.7

func CheckPasswordHash(passwordhash, hash string) bool

func CompareUsername

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

func CreateAdmin added in v0.1.0

func CreateAdmin(mongoconn *mongo.Database, collection string, admindata Admin) interface{}

func CreateUser added in v0.0.7

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

< --- FUNCTION USER --->

func DecodeGetNPM added in v0.2.3

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

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 DeleteDataUser added in v0.1.8

func DeleteDataUser(MongoConn *mongo.Database, colname string, npm string) (*mongo.DeleteResult, error)

func DeleteOneDoc added in v0.1.4

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

func DeleteUser added in v0.0.7

func DeleteUser(Mongoenv, publickey, dbname, colname string, r *http.Request) string

func EncodeWithRole

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

func GCFDeleteDataUser added in v0.1.8

func GCFDeleteDataUser(Mongostring, dbname, colname string, r *http.Request) string

func GCFReturnStruct added in v0.0.7

func GCFReturnStruct(DataStuct any) string

func GCFUpdateDataUser added in v0.1.8

func GCFUpdateDataUser(Mongostring, dbname, colname string, r *http.Request) string

func GetAllDataUser added in v0.2.0

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

func GetAllDocs added in v0.1.4

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

func GetConnectionMongo added in v0.0.7

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

func GetOneDataUserNPM added in v0.2.1

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

func HashPassword added in v0.0.7

func HashPassword(passwordhash string) (string, error)

func InsertAdmindata added in v0.1.0

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

func InsertOneDoc

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

func InsertSatuDoc added in v0.1.4

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

dipake

func InsertUserdata

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

func IsPasswordValid added in v0.0.7

func IsPasswordValid(mongoconn *mongo.Database, collection string, userdata User) bool

func IsPasswordValidEmail added in v0.1.4

func IsPasswordValidEmail(mongoconn *mongo.Database, collection string, userdata User) bool

func IsPasswordValidEmailAdmin added in v0.2.6

func IsPasswordValidEmailAdmin(mongoconn *mongo.Database, collection string, admindata Admin) bool

func LoginAdmin added in v0.1.4

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

func LoginUserEmail added in v0.2.5

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

func LoginUserNPM added in v0.2.5

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

< --- FUNCTION USER --->

func MongoConnect added in v0.1.4

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

mongodb

func Register added in v0.1.4

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

func RegisterAdmin added in v0.0.7

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

func ReturnStringStruct

func ReturnStringStruct(Data any) string

func SetConnection added in v0.0.7

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

func TokenEncoder

func TokenEncoder(username, privatekey string) string

func UpdateDataUser added in v0.1.8

func UpdateDataUser(MongoConn *mongo.Database, colname, npm, Username, Email, Role string) error

func UpdateOneDoc added in v0.1.4

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

func UpdateUser added in v0.2.7

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

func UpdateUserData added in v0.2.7

func UpdateUserData(mongoconn *mongo.Database, collection string, filter bson.M, usr User) interface{}

Types

type Admin added in v0.0.7

type Admin struct {
	Username     string `json:"username" bson:"username"`
	Password     string `json:"password" bson:"password"`
	PasswordHash string `json:"passwordhash" bson:"passwordhash"`
	Email        string `bson:"email,omitempty" json:"email,omitempty"`
	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"`
}

type Cred added in v0.2.2

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

type Credential added in v0.0.7

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 Credents added in v0.1.8

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

type EmailValidator added in v0.1.4

type EmailValidator struct {
	// contains filtered or unexported fields
}

EmailValidator adalah tipe khusus untuk validasi email npm@std.ulbi.ac.id

func NewEmailValidator added in v0.1.4

func NewEmailValidator() *EmailValidator

func (*EmailValidator) IsValid added in v0.1.4

func (v *EmailValidator) IsValid(email string) bool

IsValid memeriksa apakah email sesuai dengan pola npm@std.ulbi.ac.id

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 RequestUser added in v0.2.4

type RequestUser struct {
	NPM string `json:"npm" bson:"npm"`
}

type Response

type Response struct {
	Status  bool   `json:"status" bson:"status"`
	Message string `json:"message" bson:"message"`
	Data    []User `json:"data" bson:"data"`
}

type ResponseEncode

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

type ResponseGet added in v0.1.5

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

type ResponseUser added in v0.2.4

type ResponseUser struct {
	Status  bool   `json:"status" bson:"status"`
	Message string `json:"message" bson:"message"`
	Data    User   `json:"data" bson:"data"`
}

type User

type User struct {
	UsernameId   string `json:"usernameid" bson:"usernameid"`
	Username     string `json:"username" bson:"username"`
	NPM          string `json:"npm" bson:"npm"`
	Password     string `json:"password" bson:"password"`
	PasswordHash string `json:"passwordhash" bson:"passwordhash"`
	Email        string `bson:"email,omitempty" json:"email,omitempty"`
	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 GetAllUser

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

dipake

func GetOneUser

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

func GetOneUserNPM added in v0.2.1

func GetOneUserNPM(mongoconn *mongo.Database, colname, UserId string) (usr User)

Jump to

Keyboard shortcuts

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