Commit 4bf29f62 authored by Jan Koester's avatar Jan Koester
Browse files

auth: Anmeldung mit Mailadresse, Kontoname als Rueckfall

Mit gesetzter Domain (Seitenadresse) ging "name@firma.de" unveraendert an
authdb, das Konten nur ueber den Kontonamen (sAMAccountName) findet. Schlaegt
die Anmeldung fehl, wird jetzt der Teil vor dem '@' versucht (login und
Apilogin), wie es der Editor schon tut.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 6ca75521
Loading
Loading
Loading
Loading
+18 −0
Changes for src/auth.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -230,7 +230,16 @@ void blogi::Auth::login(const int tid,const char* username, const char* password
        throw httpException;
    }

    // authdb knows accounts by their account name (sAMAccountName), not by the
    // mail address: "c.vogel@example.de" fails when the account is "c.vogel".
    // Try the name as typed first, then the part before the '@'.
    try {
        _doLoginWithFailover(srcs, user.c_str(), password, authid, tid, &ssid);
    } catch (...) {
        if(user == userNameOnly || userNameOnly.empty())
            throw;
        _doLoginWithFailover(srcs, userNameOnly.c_str(), password, authid, tid, &ssid);
    }
}

void blogi::Auth::Apilogin(const int tid,const char *username,const char *password,uuid::uuid &authid, const std::string &domain){
@@ -269,7 +278,16 @@ void blogi::Auth::Apilogin(const int tid,const char *username,const char *passwo
        throw httpException;
    }

    // authdb knows accounts by their account name (sAMAccountName), not by the
    // mail address: "c.vogel@example.de" fails when the account is "c.vogel".
    // Try the name as typed first, then the part before the '@'.
    try {
        _doLoginWithFailover(srcs, user.c_str(), password, authid, tid, nullptr);
    } catch (...) {
        if(user == userNameOnly || userNameOnly.empty())
            throw;
        _doLoginWithFailover(srcs, userNameOnly.c_str(), password, authid, tid, nullptr);
    }
}

static constexpr std::chrono::seconds LOGIN_CACHE_TTL{30};