diff options
Diffstat (limited to 'cmd/web/handlers/login.go')
| -rw-r--r-- | cmd/web/handlers/login.go | 26 |
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, } |
