generated from VLADIMIR/template
update claims
This commit is contained in:
+48
-13
@@ -3,7 +3,6 @@ package app
|
||||
import (
|
||||
"context"
|
||||
|
||||
"evening_detective_server/internal/modules/processor_jwt"
|
||||
"evening_detective_server/internal/modules/roles"
|
||||
proto "evening_detective_server/proto"
|
||||
|
||||
@@ -19,7 +18,10 @@ func nilIfEmpty(value string) *string {
|
||||
}
|
||||
|
||||
func (s *server) AddGame(ctx context.Context, req *proto.AddGameReq) (*proto.AddGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -49,7 +51,10 @@ func (s *server) AddGame(ctx context.Context, req *proto.AddGameReq) (*proto.Add
|
||||
}
|
||||
|
||||
func (s *server) DeleteGame(ctx context.Context, req *proto.DeleteGameReq) (*proto.DeleteGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -68,7 +73,10 @@ func (s *server) DeleteGame(ctx context.Context, req *proto.DeleteGameReq) (*pro
|
||||
}
|
||||
|
||||
func (s *server) GetGame(ctx context.Context, req *proto.GetGameReq) (*proto.GetGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -86,7 +94,10 @@ func (s *server) GetGame(ctx context.Context, req *proto.GetGameReq) (*proto.Get
|
||||
}
|
||||
|
||||
func (s *server) GetGameAnswers(ctx context.Context, req *proto.GetGameAnswersReq) (*proto.GetGameAnswersRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -105,7 +116,10 @@ func (s *server) GetGameAnswers(ctx context.Context, req *proto.GetGameAnswersRe
|
||||
}
|
||||
|
||||
func (s *server) GetGameResults(ctx context.Context, req *proto.GetGameResultsReq) (*proto.GetGameResultsRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -124,7 +138,10 @@ func (s *server) GetGameResults(ctx context.Context, req *proto.GetGameResultsRe
|
||||
}
|
||||
|
||||
func (s *server) GetGames(ctx context.Context, req *proto.GetGamesReq) (*proto.GetGamesRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -142,7 +159,10 @@ func (s *server) GetGames(ctx context.Context, req *proto.GetGamesReq) (*proto.G
|
||||
}
|
||||
|
||||
func (s *server) UpdateGame(ctx context.Context, req *proto.UpdateGameReq) (*proto.UpdateGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -171,7 +191,10 @@ func (s *server) UpdateGame(ctx context.Context, req *proto.UpdateGameReq) (*pro
|
||||
}
|
||||
|
||||
func (s *server) StartGame(ctx context.Context, req *proto.StartGameReq) (*proto.StartGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -187,7 +210,10 @@ func (s *server) StartGame(ctx context.Context, req *proto.StartGameReq) (*proto
|
||||
}
|
||||
|
||||
func (s *server) PauseGame(ctx context.Context, req *proto.PauseGameReq) (*proto.PauseGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -203,7 +229,10 @@ func (s *server) PauseGame(ctx context.Context, req *proto.PauseGameReq) (*proto
|
||||
}
|
||||
|
||||
func (s *server) PlayGame(ctx context.Context, req *proto.PlayGameReq) (*proto.PlayGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -219,7 +248,10 @@ func (s *server) PlayGame(ctx context.Context, req *proto.PlayGameReq) (*proto.P
|
||||
}
|
||||
|
||||
func (s *server) FinishGame(ctx context.Context, req *proto.FinishGameReq) (*proto.FinishGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -235,7 +267,10 @@ func (s *server) FinishGame(ctx context.Context, req *proto.FinishGameReq) (*pro
|
||||
}
|
||||
|
||||
func (s *server) ResetGame(ctx context.Context, req *proto.ResetGameReq) (*proto.ResetGameRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Organizer) && !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user