saslplain: use CZNC::AuthUser()

1. this should work better with modules such as imapauth
2. it fixes a null pointer dereference when the username wasn't found

This module won't work as is yet, and has some other obvious issues with
this approach, but was a good starting point.
This commit is contained in:
Alexey Sokolov
2025-02-13 20:56:02 +00:00
parent 41a0030fdb
commit c6ae8d16e5

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2018 ZNC, see the NOTICE file for details.
* Copyright (C) 2004-2025 ZNC, see the NOTICE file for details.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,15 +41,8 @@ class CSASLMechanismPlain : public CModule {
return HALTMODS;
}
auto pUser = CZNC::Get().FindUser(sAuthcId);
if (!sAuthcId.empty() && !sPassword.empty()) {
if (pUser->CheckPass(sPassword)) {
bAuthenticationSuccess = true;
sUser = sAuthcId;
}
}
auto spAuth = std::make_shared<CClientAuth>(this, sAuthcId, sPassword);
CZNC::Get().AuthUser(spAuth);
return HALTMODS;
}