aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/handlers/login.go
diff options
context:
space:
mode:
authorSamuel Johnson <[email protected]>2025-11-25 20:52:35 -0500
committerSamuel Johnson <[email protected]>2025-11-25 20:52:35 -0500
commit44d6620b32f31c04663c9e08a1c3954273230ee8 (patch)
treea87cf977313ec95f050d7cdbbebd8bdae7c00ab2 /cmd/web/handlers/login.go
parent12602302f28478a9e4ef91e66f68347a4d76f8a6 (diff)
Tidy the code
Diffstat (limited to 'cmd/web/handlers/login.go')
-rw-r--r--cmd/web/handlers/login.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/cmd/web/handlers/login.go b/cmd/web/handlers/login.go
index f912977..3b1ee92 100644
--- a/cmd/web/handlers/login.go
+++ b/cmd/web/handlers/login.go
@@ -15,7 +15,7 @@ import (
type loginContext struct {
err *log.Logger
- db *sql.DB
+ db *sql.DB
}
func (ctx *loginContext) index(w http.ResponseWriter, r *http.Request) {
@@ -82,7 +82,7 @@ func (ctx *loginContext) login(w http.ResponseWriter, r *http.Request) {
ctx.err.Printf("Failed to retrieve user info from DB: %v\n", err)
return
}
-
+
passOneErr := bcrypt.CompareHashAndPassword([]byte(u.PassOne), []byte(passOne))
passTwoErr := bcrypt.CompareHashAndPassword([]byte(u.PassTwo), []byte(passTwo))
if passOneErr != nil || passTwoErr != nil {
@@ -92,13 +92,13 @@ func (ctx *loginContext) login(w http.ResponseWriter, r *http.Request) {
}
cookie := http.Cookie{
- Name: "paterissa_session_token",
- Value: uuid.New().String(),
- Expires: time.Now().AddDate(0, 0, 1),
- Path: "/",
- Domain: os.Getenv("serv"),
+ Name: "paterissa_session_token",
+ Value: uuid.New().String(),
+ Expires: time.Now().AddDate(0, 0, 1),
+ Path: "/",
+ Domain: os.Getenv("serv"),
HttpOnly: true,
- Secure: true,
+ Secure: true,
}
commit, err := ctx.db.Prepare("INSERT INTO cookies (content, user_id, expiration) VALUES ($1, $2, $3);")
@@ -147,11 +147,11 @@ func (ctx *loginContext) logout(w http.ResponseWriter, r *http.Request) {
}
cookie = &http.Cookie{
- Name: "paterissa_session_token",
- Value: "",
- Path: "/",
- Domain: os.Getenv("serv"),
- MaxAge: -1,
+ Name: "paterissa_session_token",
+ Value: "",
+ Path: "/",
+ Domain: os.Getenv("serv"),
+ MaxAge: -1,
HttpOnly: true,
}