generated from VLADIMIR/template
update claims
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -12,7 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func (s *server) AddScenarioPlace(ctx context.Context, req *proto.AddScenarioPlaceReq) (*proto.AddScenarioPlaceRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -34,7 +36,10 @@ func (s *server) AddScenarioPlace(ctx context.Context, req *proto.AddScenarioPla
|
||||
}
|
||||
|
||||
func (s *server) UpdateScenarioPlace(ctx context.Context, req *proto.UpdateScenarioPlaceReq) (*proto.UpdateScenarioPlaceRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -57,7 +62,10 @@ func (s *server) UpdateScenarioPlace(ctx context.Context, req *proto.UpdateScena
|
||||
}
|
||||
|
||||
func (s *server) DeleteScenarioPlace(ctx context.Context, req *proto.DeleteScenarioPlaceReq) (*proto.DeleteScenarioPlaceRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -79,7 +87,10 @@ func (s *server) DeleteScenarioPlace(ctx context.Context, req *proto.DeleteScena
|
||||
}
|
||||
|
||||
func (s *server) AddScenarioQuestion(ctx context.Context, req *proto.AddScenarioQuestionReq) (*proto.AddScenarioQuestionRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -101,7 +112,10 @@ func (s *server) AddScenarioQuestion(ctx context.Context, req *proto.AddScenario
|
||||
}
|
||||
|
||||
func (s *server) UpdateScenarioQuestion(ctx context.Context, req *proto.UpdateScenarioQuestionReq) (*proto.UpdateScenarioQuestionRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -124,7 +138,10 @@ func (s *server) UpdateScenarioQuestion(ctx context.Context, req *proto.UpdateSc
|
||||
}
|
||||
|
||||
func (s *server) DeleteScenarioQuestion(ctx context.Context, req *proto.DeleteScenarioQuestionReq) (*proto.DeleteScenarioQuestionRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -146,7 +163,10 @@ func (s *server) DeleteScenarioQuestion(ctx context.Context, req *proto.DeleteSc
|
||||
}
|
||||
|
||||
func (s *server) UpdateScenarioBackground(ctx context.Context, req *proto.UpdateScenarioBackgroundReq) (*proto.UpdateScenarioBackgroundRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -168,7 +188,10 @@ func (s *server) UpdateScenarioBackground(ctx context.Context, req *proto.Update
|
||||
}
|
||||
|
||||
func (s *server) UpdateScenarioIntro(ctx context.Context, req *proto.UpdateScenarioIntroReq) (*proto.UpdateScenarioIntroRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
@@ -190,7 +213,10 @@ func (s *server) UpdateScenarioIntro(ctx context.Context, req *proto.UpdateScena
|
||||
}
|
||||
|
||||
func (s *server) UpdateScenarioConclusion(ctx context.Context, req *proto.UpdateScenarioConclusionReq) (*proto.UpdateScenarioConclusionRsp, error) {
|
||||
claims := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
claims, claimsErr := claimsFromContext(ctx)
|
||||
if claimsErr != nil {
|
||||
return nil, claimsErr
|
||||
}
|
||||
if !roles.HasRole(claims, roles.Author) {
|
||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user