aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/auth/auth.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/auth/auth.go')
-rw-r--r--backend/auth/auth.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/backend/auth/auth.go b/backend/auth/auth.go
index 6b358c3..a8b9050 100644
--- a/backend/auth/auth.go
+++ b/backend/auth/auth.go
@@ -4,6 +4,8 @@ import (
"context"
"fmt"
+ "golang.org/x/crypto/bcrypt"
+
"github.com/nsfisis/iosdc-2024-albatross/backend/db"
)
@@ -12,7 +14,15 @@ func Login(ctx context.Context, queries *db.Queries, username, password string)
if err != nil {
return 0, err
}
- if userAuth.AuthType == "bypass" {
+ if userAuth.AuthType == "password" {
+ passwordHash := userAuth.PasswordHash
+ if passwordHash == nil {
+ panic("inconsistant data")
+ }
+ err := bcrypt.CompareHashAndPassword([]byte(*passwordHash), []byte(password))
+ if err != nil {
+ return 0, err
+ }
return int(userAuth.UserID), nil
}
return 0, fmt.Errorf("not implemented")