add jwt authentication, and fix cours for next js
This commit is contained in:
1 parent
3026f89f2e
commit
05b8d55d0e
17 files changed
+471
-64
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user