mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
21 lines
453 B
Go
21 lines
453 B
Go
package auth
|
|
|
|
import (
|
|
"tinyauth/internal/types"
|
|
|
|
"golang.org/x/crypto/bcrypt"
|
|
)
|
|
|
|
func FindUser(userList types.UserList, username string) (*types.User) {
|
|
for _, user := range userList.Users {
|
|
if user.Username == username {
|
|
return &user
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CheckPassword(user types.User, password string) bool {
|
|
hashedPasswordErr := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
|
return hashedPasswordErr == nil
|
|
} |