diff --git a/database/connection.go b/database/connection.go index 185ecbe..372ae8e 100644 --- a/database/connection.go +++ b/database/connection.go @@ -10,18 +10,15 @@ import ( // Connect returns a new database connection func Connect(app *app.App) *sql.DB { - // Set connection parameters from config postgresConfig := fmt.Sprintf("host=%s port=%s user=%s "+ "password=%s dbname=%s sslmode=disable", app.Config.Db.Ip, app.Config.Db.Port, app.Config.Db.User, app.Config.Db.Password, app.Config.Db.Name) - // Create connection db, err := sql.Open("postgres", postgresConfig) if err != nil { panic(err) } - // Test connection err = db.Ping() if err != nil { panic(err) diff --git a/models/session.go b/models/session.go index b69976d..ffe8130 100644 --- a/models/session.go +++ b/models/session.go @@ -53,7 +53,6 @@ func CreateSession(app *app.App, w http.ResponseWriter, userId int64, remember b return CreateSession(app, w, userId, remember) } - // Insert session into database err = app.Db.QueryRow(insertSession, session.UserId, session.AuthToken, session.RememberMe, session.CreatedAt).Scan(&session.Id) if err != nil { log.Println("Error inserting session into database") @@ -76,7 +75,7 @@ func GetSessionByAuthToken(app *app.App, authToken string) (Session, error) { return session, nil } -// Generates a random 64-byte string +// generateAuthToken generates a random 64-byte string func generateAuthToken(app *app.App) string { b := make([]byte, 64) _, err := rand.Read(b)