handlePass method
Implementation
void handlePass(String argument, FtpSession session) {
if (session.cachedUsername == null) {
session.sendResponse('503 Bad sequence of commands');
return;
}
// No credentials configured — accept anyone
if (session.username == null && session.password == null) {
session.isAuthenticated = true;
session.sendResponse('230 User logged in, proceed');
return;
}
// Validate only the non-null credentials
final userOk =
session.username == null || session.cachedUsername == session.username;
final passOk = session.password == null || argument == session.password;
if (userOk && passOk) {
session.isAuthenticated = true;
session.sendResponse('230 User logged in, proceed');
} else {
session.sendResponse('530 Not logged in');
}
}