Disable user registration with a flag
This commit is contained in:
@@ -2,11 +2,13 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"local/oauth2/oauth2server/config"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (s *Server) Routes() error {
|
||||
endpoints := []struct {
|
||||
skip bool
|
||||
path string
|
||||
handler http.HandlerFunc
|
||||
}{
|
||||
@@ -23,16 +25,21 @@ func (s *Server) Routes() error {
|
||||
handler: s.usersLog,
|
||||
},
|
||||
{
|
||||
skip: !config.UserRegistration,
|
||||
path: fmt.Sprintf("users/register"),
|
||||
handler: s.usersRegister,
|
||||
},
|
||||
{
|
||||
skip: !config.UserRegistration,
|
||||
path: fmt.Sprintf("users/submit"),
|
||||
handler: s.usersSubmit,
|
||||
},
|
||||
}
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
if endpoint.skip {
|
||||
continue
|
||||
}
|
||||
if err := s.Add(endpoint.path, endpoint.handler); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user