Skip to content

Setup conditional checks #1

@m19c

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

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