1
0
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:
Yohann D'ANELLO
2021-01-08 22:23:33 +01:00
parent 7e0ee7aba5
commit e47aefd6df
4 changed files with 9 additions and 9 deletions

View File

@ -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