aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/admin_auth_ldap.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/admin_auth_ldap.go')
-rw-r--r--cmd/admin_auth_ldap.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/cmd/admin_auth_ldap.go b/cmd/admin_auth_ldap.go
index feeaf17661..e95e1d15c6 100644
--- a/cmd/admin_auth_ldap.go
+++ b/cmd/admin_auth_ldap.go
@@ -8,7 +8,7 @@ import (
"fmt"
"strings"
- "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/login"
"code.gitea.io/gitea/services/auth/source/ldap"
"github.com/urfave/cli"
@@ -17,9 +17,9 @@ import (
type (
authService struct {
initDB func() error
- createLoginSource func(loginSource *models.LoginSource) error
- updateLoginSource func(loginSource *models.LoginSource) error
- getLoginSourceByID func(id int64) (*models.LoginSource, error)
+ createLoginSource func(loginSource *login.Source) error
+ updateLoginSource func(loginSource *login.Source) error
+ getLoginSourceByID func(id int64) (*login.Source, error)
}
)
@@ -164,14 +164,14 @@ var (
func newAuthService() *authService {
return &authService{
initDB: initDB,
- createLoginSource: models.CreateLoginSource,
- updateLoginSource: models.UpdateSource,
- getLoginSourceByID: models.GetLoginSourceByID,
+ createLoginSource: login.CreateSource,
+ updateLoginSource: login.UpdateSource,
+ getLoginSourceByID: login.GetSourceByID,
}
}
// parseLoginSource assigns values on loginSource according to command line flags.
-func parseLoginSource(c *cli.Context, loginSource *models.LoginSource) {
+func parseLoginSource(c *cli.Context, loginSource *login.Source) {
if c.IsSet("name") {
loginSource.Name = c.String("name")
}
@@ -269,7 +269,7 @@ func findLdapSecurityProtocolByName(name string) (ldap.SecurityProtocol, bool) {
// getLoginSource gets the login source by its id defined in the command line flags.
// It returns an error if the id is not set, does not match any source or if the source is not of expected type.
-func (a *authService) getLoginSource(c *cli.Context, loginType models.LoginType) (*models.LoginSource, error) {
+func (a *authService) getLoginSource(c *cli.Context, loginType login.Type) (*login.Source, error) {
if err := argsSet(c, "id"); err != nil {
return nil, err
}
@@ -280,7 +280,7 @@ func (a *authService) getLoginSource(c *cli.Context, loginType models.LoginType)
}
if loginSource.Type != loginType {
- return nil, fmt.Errorf("Invalid authentication type. expected: %s, actual: %s", models.LoginNames[loginType], models.LoginNames[loginSource.Type])
+ return nil, fmt.Errorf("Invalid authentication type. expected: %s, actual: %s", loginType.String(), loginSource.Type.String())
}
return loginSource, nil
@@ -296,8 +296,8 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
return err
}
- loginSource := &models.LoginSource{
- Type: models.LoginLDAP,
+ loginSource := &login.Source{
+ Type: login.LDAP,
IsActive: true, // active by default
Cfg: &ldap.Source{
Enabled: true, // always true
@@ -318,7 +318,7 @@ func (a *authService) updateLdapBindDn(c *cli.Context) error {
return err
}
- loginSource, err := a.getLoginSource(c, models.LoginLDAP)
+ loginSource, err := a.getLoginSource(c, login.LDAP)
if err != nil {
return err
}
@@ -341,8 +341,8 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
return err
}
- loginSource := &models.LoginSource{
- Type: models.LoginDLDAP,
+ loginSource := &login.Source{
+ Type: login.DLDAP,
IsActive: true, // active by default
Cfg: &ldap.Source{
Enabled: true, // always true
@@ -363,7 +363,7 @@ func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
return err
}
- loginSource, err := a.getLoginSource(c, models.LoginDLDAP)
+ loginSource, err := a.getLoginSource(c, login.DLDAP)
if err != nil {
return err
}