Skip to content

Setup conditional checks #1

Description

@m19c

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) {
		// ...
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions