diff --git a/domain/user.go b/domain/user.go index 348df954..20d6d69a 100644 --- a/domain/user.go +++ b/domain/user.go @@ -24,7 +24,7 @@ type UserRepository interface { ReNewMyiCalSecret(info *ConInfo) (string, error) GetMyiCalSecret(info *ConInfo) (string, error) - IsPrevilege(info *ConInfo) bool + IsPrivilege(info *ConInfo) bool GrantPrivilege(userID uuid.UUID) error SyncUsers(info *ConInfo) error } diff --git a/infra/db/user.go b/infra/db/user.go index 34f42c5a..d7b16368 100644 --- a/infra/db/user.go +++ b/infra/db/user.go @@ -70,7 +70,7 @@ func (repo *GormRepository) SyncUsers(users []*User) error { // saveUser user.IcalSecret == "" の時、値は更新されません。 // また、user.Provider, user.Tokenは空の時、更新されません。 -// user.Previlegeは常に更新されません。 +// user.Privilegeは常に更新されません。 func saveUser(db *gorm.DB, user *User) (*User, error) { err := db.Transaction(func(tx *gorm.DB) error { existingUser, err := getUser(tx.Preload("Provider").Preload("Token"), user.ID) diff --git a/repository/room.go b/repository/room.go index d57533de..c076e851 100644 --- a/repository/room.go +++ b/repository/room.go @@ -19,7 +19,7 @@ func (repo *Repository) CreateUnVerifiedRoom(params domain.WriteRoomParams, info } func (repo *Repository) CreateVerifiedRoom(params domain.WriteRoomParams, info *domain.ConInfo) (*domain.Room, error) { - if !repo.IsPrevilege(info) { + if !repo.IsPrivilege(info) { return nil, domain.ErrForbidden } p := db.CreateRoomParams{ @@ -46,7 +46,7 @@ func (repo *Repository) UpdateRoom(roomID uuid.UUID, params domain.WriteRoomPara } func (repo *Repository) VerifyRoom(roomID uuid.UUID, info *domain.ConInfo) error { - if !repo.IsPrevilege(info) { + if !repo.IsPrivilege(info) { return domain.ErrForbidden } err := repo.GormRepo.UpdateRoomVerified(roomID, true) @@ -54,7 +54,7 @@ func (repo *Repository) VerifyRoom(roomID uuid.UUID, info *domain.ConInfo) error } func (repo *Repository) UnVerifyRoom(roomID uuid.UUID, info *domain.ConInfo) error { - if !repo.IsPrevilege(info) { + if !repo.IsPrivilege(info) { return domain.ErrForbidden } err := repo.GormRepo.UpdateRoomVerified(roomID, false) diff --git a/repository/user.go b/repository/user.go index 6c9aaedb..9aa4956c 100644 --- a/repository/user.go +++ b/repository/user.go @@ -14,7 +14,7 @@ import ( const traQIssuerName = "traQ" func (repo *Repository) SyncUsers(info *domain.ConInfo) error { - if !repo.IsPrevilege(info) { + if !repo.IsPrivilege(info) { return domain.ErrForbidden } t, err := repo.GormRepo.GetToken(info.ReqUserID) @@ -174,7 +174,7 @@ func (repo *Repository) GetMyiCalSecret(info *domain.ConInfo) (string, error) { return user.IcalSecret, nil } -func (repo *Repository) IsPrevilege(info *domain.ConInfo) bool { +func (repo *Repository) IsPrivilege(info *domain.ConInfo) bool { user, err := repo.GormRepo.GetUser(info.ReqUserID) if err != nil { return false @@ -185,7 +185,7 @@ func (repo *Repository) IsPrevilege(info *domain.ConInfo) bool { func traQUserMap(users []traq.User) map[uuid.UUID]*traq.User { userMap := make(map[uuid.UUID]*traq.User) for _, u := range users { - user:=u + user := u userMap[uuid.Must(uuid.FromString(user.GetId()))] = &user } return userMap diff --git a/router/middleware.go b/router/middleware.go index c29dfdf3..77feb07d 100644 --- a/router/middleware.go +++ b/router/middleware.go @@ -102,11 +102,11 @@ func (h *Handlers) TraQUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc { } } -// PrevilegeUserMiddleware 管理者ユーザーか判定するミドルウェア -func (h *Handlers) PrevilegeUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc { +// PrivilegeUserMiddleware 管理者ユーザーか判定するミドルウェア +func (h *Handlers) PrivilegeUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { // 判定 - if !h.Repo.IsPrevilege(getConinfo(c)) { + if !h.Repo.IsPrivilege(getConinfo(c)) { return forbidden( errors.New("not admin"), message("You are not admin user."), diff --git a/router/router.go b/router/router.go index 52a229dc..8cb18fcc 100644 --- a/router/router.go +++ b/router/router.go @@ -112,11 +112,11 @@ func (h *Handlers) SetupRoute() *echo.Echo { roomsAPI.DELETE("/:roomid", h.HandleDeleteRoom) // サービス管理者権限が必要 - roomsAPIWithPrevilegeAuth := roomsAPI.Group("", h.PrevilegeUserMiddleware) + roomsAPIWithPrivilegeAuth := roomsAPI.Group("", h.PrivilegeUserMiddleware) { - roomsAPIWithPrevilegeAuth.POST("/all", h.HandleCreateVerifedRooms) - roomsAPIWithPrevilegeAuth.POST("/:roomid/verified", h.HandleVerifyRoom) - roomsAPIWithPrevilegeAuth.DELETE("/:roomid/verified", h.HandleUnVerifyRoom) + roomsAPIWithPrivilegeAuth.POST("/all", h.HandleCreateVerifedRooms) + roomsAPIWithPrivilegeAuth.POST("/:roomid/verified", h.HandleVerifyRoom) + roomsAPIWithPrivilegeAuth.DELETE("/:roomid/verified", h.HandleUnVerifyRoom) } } @@ -132,10 +132,10 @@ func (h *Handlers) SetupRoute() *echo.Echo { usersAPI.GET("/:userid/groups", h.HandleGetGroupIDsByUserID) // サービス管理者権限が必要 - usersAPIWithPrevilegeAuth := usersAPI.Group("", h.PrevilegeUserMiddleware) + usersAPIWithPrivilegeAuth := usersAPI.Group("", h.PrivilegeUserMiddleware) { - usersAPIWithPrevilegeAuth.PATCH("/:userid/privileged", h.HandleGrantPrivilege) - usersAPIWithPrevilegeAuth.POST("/sync", h.HandleSyncUser) + usersAPIWithPrivilegeAuth.PATCH("/:userid/privileged", h.HandleGrantPrivilege) + usersAPIWithPrivilegeAuth.POST("/sync", h.HandleSyncUser) } }