@@ -31,16 +31,16 @@ const (
31
31
LoginNotype LoginType = iota
32
32
LoginPlain // 1
33
33
LoginLdap // 2
34
- LOGIN_SMTP // 3
35
- LOGIN_PAM // 4
36
- LOGIN_DLDAP // 5
34
+ LoginSmtp // 3
35
+ LoginPam // 4
36
+ LoginDldap // 5
37
37
)
38
38
39
39
var LoginNames = map [LoginType ]string {
40
40
LoginLdap : "LDAP (via BindDN)" ,
41
- LOGIN_DLDAP : "LDAP (simple auth)" , // Via direct bind
42
- LOGIN_SMTP : "SMTP" ,
43
- LOGIN_PAM : "PAM" ,
41
+ LoginDldap : "LDAP (simple auth)" , // Via direct bind
42
+ LoginSmtp : "SMTP" ,
43
+ LoginPam : "PAM" ,
44
44
}
45
45
46
46
var SecurityProtocolNames = map [ldap.SecurityProtocol ]string {
@@ -139,11 +139,11 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) {
139
139
switch colName {
140
140
case "type" :
141
141
switch LoginType (Cell2Int64 (val )) {
142
- case LoginLdap , LOGIN_DLDAP :
142
+ case LoginLdap , LoginDldap :
143
143
source .Cfg = new (LDAPConfig )
144
- case LOGIN_SMTP :
144
+ case LoginSmtp :
145
145
source .Cfg = new (SMTPConfig )
146
- case LOGIN_PAM :
146
+ case LoginPam :
147
147
source .Cfg = new (PAMConfig )
148
148
default :
149
149
panic ("unrecognized login source type: " + com .ToStr (* val ))
@@ -169,15 +169,15 @@ func (source *LoginSource) IsLDAP() bool {
169
169
}
170
170
171
171
func (source * LoginSource ) IsDLDAP () bool {
172
- return source .Type == LOGIN_DLDAP
172
+ return source .Type == LoginDldap
173
173
}
174
174
175
175
func (source * LoginSource ) IsSMTP () bool {
176
- return source .Type == LOGIN_SMTP
176
+ return source .Type == LoginSmtp
177
177
}
178
178
179
179
func (source * LoginSource ) IsPAM () bool {
180
- return source .Type == LOGIN_PAM
180
+ return source .Type == LoginPam
181
181
}
182
182
183
183
func (source * LoginSource ) HasTLS () bool {
@@ -188,9 +188,9 @@ func (source *LoginSource) HasTLS() bool {
188
188
189
189
func (source * LoginSource ) UseTLS () bool {
190
190
switch source .Type {
191
- case LoginLdap , LOGIN_DLDAP :
191
+ case LoginLdap , LoginDldap :
192
192
return source .LDAP ().SecurityProtocol != ldap .SECURITY_PROTOCOL_UNENCRYPTED
193
- case LOGIN_SMTP :
193
+ case LoginSmtp :
194
194
return source .SMTP ().TLS
195
195
}
196
196
@@ -199,9 +199,9 @@ func (source *LoginSource) UseTLS() bool {
199
199
200
200
func (source * LoginSource ) SkipVerify () bool {
201
201
switch source .Type {
202
- case LoginLdap , LOGIN_DLDAP :
202
+ case LoginLdap , LoginDldap :
203
203
return source .LDAP ().SkipVerify
204
- case LOGIN_SMTP :
204
+ case LoginSmtp :
205
205
return source .SMTP ().SkipVerify
206
206
}
207
207
@@ -293,7 +293,7 @@ func composeFullName(firstname, surname, username string) string {
293
293
// LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
294
294
// and create a local user if success when enabled.
295
295
func LoginViaLDAP (user * User , login , passowrd string , source * LoginSource , autoRegister bool ) (* User , error ) {
296
- username , fn , sn , mail , isAdmin , succeed := source .Cfg .(* LDAPConfig ).SearchEntry (login , passowrd , source .Type == LOGIN_DLDAP )
296
+ username , fn , sn , mail , isAdmin , succeed := source .Cfg .(* LDAPConfig ).SearchEntry (login , passowrd , source .Type == LoginDldap )
297
297
if ! succeed {
298
298
// User not in LDAP, do nothing
299
299
return nil , ErrUserNotExist {0 , login }
@@ -445,7 +445,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
445
445
Name : strings .ToLower (username ),
446
446
Email : login ,
447
447
Passwd : password ,
448
- LoginType : LOGIN_SMTP ,
448
+ LoginType : LoginSmtp ,
449
449
LoginSource : sourceID ,
450
450
LoginName : login ,
451
451
IsActive : true ,
@@ -479,7 +479,7 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
479
479
Name : login ,
480
480
Email : login ,
481
481
Passwd : password ,
482
- LoginType : LOGIN_PAM ,
482
+ LoginType : LoginPam ,
483
483
LoginSource : sourceID ,
484
484
LoginName : login ,
485
485
IsActive : true ,
@@ -493,11 +493,11 @@ func ExternalUserLogin(user *User, login, password string, source *LoginSource,
493
493
}
494
494
495
495
switch source .Type {
496
- case LoginLdap , LOGIN_DLDAP :
496
+ case LoginLdap , LoginDldap :
497
497
return LoginViaLDAP (user , login , password , source , autoRegister )
498
- case LOGIN_SMTP :
498
+ case LoginSmtp :
499
499
return LoginViaSMTP (user , login , password , source .ID , source .Cfg .(* SMTPConfig ), autoRegister )
500
- case LOGIN_PAM :
500
+ case LoginPam :
501
501
return LoginViaPAM (user , login , password , source .ID , source .Cfg .(* PAMConfig ), autoRegister )
502
502
}
503
503
0 commit comments