Conversion of MailFileSystem object to MString.
This commit is contained in:
1 parent
8e7834a320
commit
09c6163a74
8 files changed
+127
-131
No files matched your search
+35
-35
@@ -1,56 +1,56 @@
|
||||
#include "__SMTP_AUTH.h"
|
||||
#include "Base64.h"
|
||||
#include "SMTPServer.h"
|
||||
|
||||
namespace mail {
|
||||
|
||||
|
||||
int __SMTP_AUTH::processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) {
|
||||
|
||||
switch(session.authState) {
|
||||
|
||||
|
||||
switch(session.authState) {
|
||||
|
||||
case USER_UNKNOWN:
|
||||
if(request[1].equals("LOGIN")) {
|
||||
session.out << "334 VXNlcm5hbWU6" << CRLF;
|
||||
session.out << "334 VXNlcm5hbWU6" << CRLF;
|
||||
// setTimer(10.0f);
|
||||
session.authState = USER_QUERY;
|
||||
session.authState = USER_QUERY;
|
||||
grabInput(session);
|
||||
}
|
||||
else {
|
||||
session.out << "504 AUTH method not supported." << CRLF;
|
||||
session.out << "504 AUTH method not supported." << CRLF;
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
||||
case USER_QUERY:
|
||||
session.userName = request[0].str();
|
||||
session.userName = request[0];
|
||||
// setTimer(0.0f);
|
||||
session.out << "334 UGFzc3dvcmQ6" << CRLF;
|
||||
session.out << "334 UGFzc3dvcmQ6" << CRLF;
|
||||
// setTimer(10.0f);
|
||||
session.authState = USER_SECRET_QUERY;
|
||||
return 1;
|
||||
|
||||
session.authState = USER_SECRET_QUERY;
|
||||
return 1;
|
||||
|
||||
case USER_SECRET_QUERY:
|
||||
session.password = request[0].str();
|
||||
// setTimer(0.0f);
|
||||
coreutils::Base64 base64;
|
||||
if(authLogin(session.userName, session.password)) {
|
||||
session.out << "235 2.7.0 Authentication successful" << CRLF;
|
||||
session.relay = true;
|
||||
session.authState = USER_KNOWN;
|
||||
clearGrab(session);
|
||||
}
|
||||
else {
|
||||
session.out << "530 Login was unsuccessful." << CRLF;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
session.password = request[0];
|
||||
// setTimer(0.0f);
|
||||
coreutils::Base64 base64;
|
||||
if(authLogin(session.userName, session.password, server)) {
|
||||
session.out << "235 2.7.0 Authentication successful" << CRLF;
|
||||
session.relay = true;
|
||||
session.authState = USER_KNOWN;
|
||||
clearGrab(session);
|
||||
}
|
||||
else {
|
||||
session.out << "530 Login was unsuccessful." << CRLF;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __SMTP_AUTH::authLogin(coreutils::ZString userName, coreutils::ZString password) {
|
||||
// std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
||||
// coreutils::File secret(secretPath);
|
||||
// secret.read();
|
||||
// return secret.asString() == password;
|
||||
return true;
|
||||
|
||||
bool __SMTP_AUTH::authLogin(coreutils::ZString &userName, coreutils::ZString &password, SMTPServer &server) {
|
||||
std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password";
|
||||
coreutils::File secret(secretPath);
|
||||
secret.read();
|
||||
return password == secret.asString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user