Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

権限の確認を行うドメインサービスを作成する #262

Open
FlowingSPDG opened this issue Aug 7, 2023 · 0 comments
Open
Assignees
Labels
backend GraphQL or API(Go) related issue.
Projects

Comments

@FlowingSPDG
Copy link
Owner

FlowingSPDG commented Aug 7, 2023

type CheckPermission interface{
	CheckMatchEditable(ctx context.Context, match *entity.Match) (bool, error)
}

type checkPermission struct{}

func (cp *checkPermission) CheckMatchEditable() (bool,error) {
	op, err := g5ctx.GetOperation(ctx)
	if err != nil {
		return false, err
	}
	switch op {
	case g5ctx.OperationTypeSystem:
		return true
	case g5ctx.OperationTypeUser:
		token, err := g5ctx.GetUserToken(ctx)
		if err != nil {
			return nil, err
		}
		if token.Admin {
			return true
		}
		if token.UserID == match.UserID {
			return true
		}
	}
	return false
}
@FlowingSPDG FlowingSPDG self-assigned this Aug 12, 2023
@FlowingSPDG FlowingSPDG changed the title 権限の確認を行うサービスを作成する [Backend] 権限の確認を行うサービスを作成する Aug 13, 2023
@FlowingSPDG FlowingSPDG changed the title [Backend] 権限の確認を行うサービスを作成する 権限の確認を行うドメインサービスを作成する Aug 13, 2023
@FlowingSPDG FlowingSPDG added the backend GraphQL or API(Go) related issue. label Aug 13, 2023
@FlowingSPDG FlowingSPDG added this to backend in v0.2.0 Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend GraphQL or API(Go) related issue.
Projects
v0.2.0
  
backend
Development

No branches or pull requests

1 participant