mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-27 16:52:06 +02:00
Replace the name of the stream if using an alias
This commit is contained in:
@ -22,11 +22,11 @@ type LDAP struct {
|
||||
|
||||
// Login tries to bind to LDAP
|
||||
// Returns (true, nil) if success
|
||||
func (a LDAP) Login(username string, password string) (bool, error) {
|
||||
func (a LDAP) Login(username string, password string) (bool, string, error) {
|
||||
aliasSplit := strings.SplitN(username, "__", 2)
|
||||
potentialUsernames := []string{username}
|
||||
|
||||
for len(aliasSplit) == 2 {
|
||||
if len(aliasSplit) == 2 {
|
||||
alias := aliasSplit[0]
|
||||
trueUsername := aliasSplit[1]
|
||||
// Resolve stream alias if necessary
|
||||
@ -45,12 +45,12 @@ func (a LDAP) Login(username string, password string) (bool, error) {
|
||||
err = a.Conn.Bind(bindDn, password)
|
||||
if err == nil {
|
||||
// Login succeeded if no error
|
||||
return true, nil
|
||||
return true, aliasSplit[0], nil
|
||||
}
|
||||
}
|
||||
|
||||
// Unable to log in
|
||||
return err == nil, err
|
||||
return err == nil, "", err
|
||||
}
|
||||
|
||||
// Close LDAP connection
|
||||
|
Reference in New Issue
Block a user