Feature/role create #5

Merged
lqhoang99 merged 8 commits from feature/RoleCreate into master 2021-11-10 06:43:29 +00:00
2 changed files with 4 additions and 0 deletions
Showing only changes of commit d423c25256 - Show all commits

View File

@ -17,6 +17,7 @@ var (
prefix string
)
// Set ...
func Set(instance *mongo.Database, tablePrefix string) {
db = instance
prefix = tablePrefix

View File

@ -7,16 +7,19 @@ import (
"golang.org/x/crypto/bcrypt"
)
// HashPassword ...
func HashPassword(password string) string {
bytes, _ := bcrypt.GenerateFromPassword([]byte(password), passwordHashingCost)
return string(bytes)
}
// CheckPasswordHash ...
func CheckPasswordHash(password, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
return err == nil
}
// GetSearchString ...
func GetSearchString(fieldList ...string) string {
var (
searchList = make([]interface{}, 0)