aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/group.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/auth/group.go')
-rw-r--r--services/auth/group.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/services/auth/group.go b/services/auth/group.go
index bf047338bb..0f40e1a76c 100644
--- a/services/auth/group.go
+++ b/services/auth/group.go
@@ -6,6 +6,8 @@ package auth
import (
"net/http"
+ "reflect"
+ "strings"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
@@ -30,6 +32,24 @@ func NewGroup(methods ...Method) *Group {
}
}
+// Add adds a new method to group
+func (b *Group) Add(method Method) {
+ b.methods = append(b.methods, method)
+}
+
+// Name returns group's methods name
+func (b *Group) Name() string {
+ names := make([]string, 0, len(b.methods))
+ for _, m := range b.methods {
+ if n, ok := m.(Named); ok {
+ names = append(names, n.Name())
+ } else {
+ names = append(names, reflect.TypeOf(m).Elem().Name())
+ }
+ }
+ return strings.Join(names, ",")
+}
+
// Init does nothing as the Basic implementation does not need to allocate any resources
func (b *Group) Init() error {
for _, method := range b.methods {