Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "2"
linters:
default: standard
settings:
errcheck: {}
staticcheck:
checks:
- "-QF1003"
severity:
default: warning
13 changes: 6 additions & 7 deletions cmd/database/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package main

import (
"fmt"
"os"
"sync"
"time"

"github.com/VATUSA/primary-api/pkg/config"
"github.com/VATUSA/primary-api/pkg/constants"
"github.com/VATUSA/primary-api/pkg/database"
"github.com/VATUSA/primary-api/pkg/database/models"
"github.com/joho/godotenv"
"gorm.io/gorm"
"os"
"sync"
"time"
)

type Facility struct {
Expand Down Expand Up @@ -102,7 +103,7 @@ func main() {
}

func MigrateFacilities(oldDbConn *gorm.DB) {
fmt.Sprintln("Migrating facilities")
fmt.Println("Migrating facilities")

var facilities []Facility
oldDbConn.Table("facilities").Find(&facilities)
Expand All @@ -125,7 +126,7 @@ func MigrateFacilities(oldDbConn *gorm.DB) {
}
}

fmt.Sprintln("Done migrating facilities")
fmt.Println("Done migrating facilities")
}

func MigrateUsers(oldDbConn *gorm.DB) {
Expand Down Expand Up @@ -200,7 +201,6 @@ func MigrateUsers(oldDbConn *gorm.DB) {
Home: true,
Visiting: false,
Status: "Active",
DeletedAt: nil,
}

if err := roster.Create(); err != nil {
Expand All @@ -220,7 +220,6 @@ func MigrateUsers(oldDbConn *gorm.DB) {
Home: false,
Visiting: true,
Status: "Active",
DeletedAt: nil,
}

if err := roster.Create(); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions pkg/go-chi/middleware/auth/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package middleware

import (
"encoding/json"
"net/http"
"strconv"

"github.com/VATUSA/primary-api/pkg/database/types"
"github.com/VATUSA/primary-api/pkg/utils"
log "github.com/sirupsen/logrus"
"net/http"
"strconv"
)

func CanViewFeedback(next http.Handler) http.Handler {
Expand Down Expand Up @@ -120,7 +121,7 @@ func CanLeaveFeedback(next http.Handler) http.Handler {

if credentials.User != nil {
if req.Status != types.Pending {
log.Error("User %d, attempted to create feedback with status: %s. No permissions.", credentials.User.CID, req.Status)
log.Errorf("User %d, attempted to create feedback with status: %s. No permissions.", credentials.User.CID, req.Status)
utils.Render(w, r, utils.ErrForbidden)
return
}
Expand Down
8 changes: 5 additions & 3 deletions views/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package views

import (
"fmt"

"github.com/VATUSA/primary-api/pkg/config"
"github.com/VATUSA/primary-api/views/docs"
_ "github.com/VATUSA/primary-api/views/docs"

"net/http"
"strings"

v3 "github.com/VATUSA/primary-api/views/v3"
"github.com/go-chi/chi/v5"
httpSwagger "github.com/swaggo/http-swagger"
"net/http"
"strings"
)

// @title VATUSA API
Expand Down
15 changes: 8 additions & 7 deletions views/v3/user/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"

"github.com/VATUSA/primary-api/pkg/config"
"github.com/VATUSA/primary-api/pkg/constants"
"github.com/VATUSA/primary-api/pkg/cookie"
Expand All @@ -14,12 +21,6 @@ import (
gonanoid "github.com/matoous/go-nanoid"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)

func GetLogin(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -292,7 +293,7 @@ func exchangeToken(ctx context.Context, oauthConfig *oauth2.Config, code string)
if err != nil {
return nil, fmt.Errorf("error sending token request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected token response status: %s", resp.Status)
Expand Down
Loading