Browse Source

Renamed CheckLogin to Login

Changed encryption cookie to be 32 bytes (64 bytes not supported)
pull/24/head
Jordan 7 years ago
parent
commit
cdb4181406
3 changed files with 3 additions and 6 deletions
  1. +2
    -3
      auth/auth.go
  2. +1
    -1
      controllers/route.go
  3. +0
    -2
      middleware/middleware.go

+ 2
- 3
auth/auth.go View File

@ -20,13 +20,12 @@ func init() {
var Store = sessions.NewCookieStore(
[]byte(securecookie.GenerateRandomKey(64)), //Signing key
[]byte(securecookie.GenerateRandomKey(64)), //Encryption key
)
[]byte(securecookie.GenerateRandomKey(32)))
// CheckLogin attempts to request a SQL record with the given username.
// If successful, it then compares the received bcrypt hash.
// If all checks pass, this function sets the session id for later use.
func CheckLogin(r *http.Request) (bool, error) {
func Login(r *http.Request) (bool, error) {
username, password := r.FormValue("username"), r.FormValue("password")
session, _ := Store.Get(r, "gophish")
stmt, err := db.Conn.Prepare("SELECT * FROM Users WHERE username=?")

+ 1
- 1
controllers/route.go View File

@ -123,7 +123,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
http.Error(w, "Error parsing request", http.StatusInternalServerError)
}
succ, err := auth.CheckLogin(r)
succ, err := auth.Login(r)
if err != nil {
http.Error(w, "Error logging in", http.StatusInternalServerError)
}

+ 0
- 2
middleware/middleware.go View File

@ -27,8 +27,6 @@ func GetContext(handler http.Handler) http.HandlerFunc {
ctx.Set(r, "user", nil)
}
handler.ServeHTTP(w, r)
// Save the session
session.Save(r, w)
// Remove context contents
ctx.Clear(r)
}

Loading…
Cancel
Save