add jwt authentication, and fix cours for next js

This commit is contained in:
Tulyaganov Shuhrat committed 2023-05-02 11:02:06 +03:00
1 parent 3026f89f2e
commit 05b8d55d0e
17 files changed
+471 -64

No files matched your search

+12 -1
View File
@@ -1,6 +1,8 @@
package password
import "golang.org/x/crypto/bcrypt"
import (
"golang.org/x/crypto/bcrypt"
)
func HashPassword(password string) (*[]byte, error) {
bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
@@ -9,3 +11,12 @@ func HashPassword(password string) (*[]byte, error) {
}
return &bytes, err
}
func CheckValid(password string, hash string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
if err != nil {
return false
}
return true
}