Skip to content

Commit

Permalink
Merge pull request #255 from cho4036/dev-rbac-tks
Browse files Browse the repository at this point in the history
bug fix: build error fix
  • Loading branch information
ktkfree authored Mar 4, 2024
2 parents 18c44cc + 2d2880e commit 1886eec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 1 addition & 3 deletions internal/delivery/http/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"net/http"

"github.com/google/uuid"
"github.com/openinfradev/tks-api/internal"
"github.com/openinfradev/tks-api/internal/middleware/audit"
"github.com/openinfradev/tks-api/internal/middleware/auth/request"
Expand Down Expand Up @@ -73,14 +72,13 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
ErrorJSON(w, r, err)
return
} else {
userId, _ := uuid.Parse(user.ID)
_, _ = h.auditUsecase.Create(r.Context(), domain.Audit{
OrganizationId: input.OrganizationId,
Group: "Auth",
Message: fmt.Sprintf("[%s]님이 로그인 하였습니다.", input.AccountId),
Description: "",
ClientIP: audit.GetClientIpAddress(w, r),
UserId: &userId,
UserId: &user.ID,
})
}

Expand Down
6 changes: 1 addition & 5 deletions internal/delivery/http/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ func (h RoleHandler) ListTksRoles(w http.ResponseWriter, r *http.Request) {

// query parameter
urlParams := r.URL.Query()
pg, err := pagination.NewPagination(&urlParams)
if err != nil {
ErrorJSON(w, r, httpErrors.NewBadRequestError(err, "", ""))
return
}
pg := pagination.NewPagination(&urlParams)

// list roles
roles, err := h.roleUsecase.ListTksRoles(organizationId, pg)
Expand Down
6 changes: 3 additions & 3 deletions internal/repository/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ type Audit struct {

ID uuid.UUID `gorm:"primarykey"`
OrganizationId string
Organization Organization `gorm:"foreignKey:OrganizationId"`
Organization domain.Organization `gorm:"foreignKey:OrganizationId"`
Group string
Message string
Description string
ClientIP string
UserId *uuid.UUID `gorm:"type:uuid"`
User User `gorm:"foreignKey:UserId"`
UserId *uuid.UUID `gorm:"type:uuid"`
User domain.User `gorm:"foreignKey:UserId"`
}

func (c *Audit) BeforeCreate(tx *gorm.DB) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/repository/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (e *EndpointRepository) List(pg *pagination.Pagination) ([]*domain.Endpoint
var endpoints []*domain.Endpoint

if pg == nil {
pg = pagination.NewDefaultPagination()
pg = pagination.NewPagination(nil)
}
filterFunc := CombinedGormFilter("endpoints", pg.GetFilters(), pg.CombinedFilter)
db := filterFunc(e.db.Model(&domain.Endpoint{}))
Expand Down
4 changes: 2 additions & 2 deletions internal/repository/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (r RoleRepository) List(pg *pagination.Pagination) ([]*domain.Role, error)
var roles []*domain.Role

if pg == nil {
pg = pagination.NewDefaultPagination()
pg = pagination.NewPagination(nil)
}
filterFunc := CombinedGormFilter("roles", pg.GetFilters(), pg.CombinedFilter)
db := filterFunc(r.db.Model(&domain.Role{}))
Expand All @@ -69,7 +69,7 @@ func (r RoleRepository) ListTksRoles(organizationId string, pg *pagination.Pagin
var roles []*domain.Role

if pg == nil {
pg = pagination.NewDefaultPagination()
pg = pagination.NewPagination(nil)
}
filterFunc := CombinedGormFilter("roles", pg.GetFilters(), pg.CombinedFilter)
db := filterFunc(r.db.Model(&domain.Role{}))
Expand Down

0 comments on commit 1886eec

Please sign in to comment.