User user;
try {
user = LXSDb::inst().getTable<User>().selectOne("username = ?", username);
}
catch (const ::ngrest::Exception& exception) {
::ngrest::LogError() << "Exception: \n" << exception.what();
NGREST_THROW_HTTP(exception.what(), ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);
}
if (user.password == password) {
ngrest::LogInfo() << "Login server successfully";
return (int) LXSDb::inst().getTable<Session>().insert({0, user.username, user.password}).lastInsertId();
} else {
ngrest::LogInfo() << "Failed to Login server";
NGREST_THROW_HTTP("Failed to login", ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);
return 0;
}
Session login;
try {
login = LXSDb::inst().getTable<Session>().selectOne("username = ?", username);
} //NGREST_CATCH_ALL
catch (const ::ngrest::Exception& exception) {
::ngrest::LogError() << "Exception: \n" << exception.what();
NGREST_THROW_HTTP(exception.what(), ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);
}
if(login.username == username && login.password == password) {
//NGREST_ASSERT_HTTP(login.username == username, ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR, "Duplicated login session" );
NGREST_THROW_HTTP("Duplicated login session", ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);
}
lxs.extel-iotlcoud.com’s server DNS address could not be found.
NGREST_THROW_HTTP("{\"msg\": \"Server - Failed to login due to incorrect password\"}", ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);
NGREST_THROW_HTTP("{\"result\":{\"msg\": \"Server - Failed to login due to incorrect password\"}}", ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR);