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

Setup conditional checks #1

Open
m19c opened this issue Oct 29, 2018 · 1 comment
Open

Setup conditional checks #1

m19c opened this issue Oct 29, 2018 · 1 comment

Comments

@m19c
Copy link
Owner

m19c commented Oct 29, 2018

POC

package acl

type Condition struct {
	parent *Condition
}

func NewCondition() *Condition {
	return &Condition{}
}

func (condition *Condition) Require(rights... string) *Condition {
	return condition
}

func (condition *Condition) Disallow(rights... string) *Condition {
	return condition
}

func (condition *Condition) And(connection *Condition) *Condition {
	return condition
}

func (condition *Condition) Or(connection *Condition) *Condition {
	return connection
}

func (condition *Condition) IsAllowed(rights ...string) *Condition {
	return condition
}

func (condition *Condition) End() *Condition {
	return condition.parent
}

Usage

func main() {
	condition := NewCondition().IsAllowed("right.a").Or(NewCondition().IsAllowed("right.b"))
	if manager.IsAllowedByCondition(condition) {
		// ...
	}
}
@skovtunenko
Copy link

awsome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants