improved ui, added panel to add new city and zone

parts of displaying cities fromdb
This commit is contained in:
2019-11-15 11:23:51 +01:00
parent cfddff4d8d
commit 36caaa214b
12 changed files with 186 additions and 207 deletions

View File

@@ -0,0 +1,48 @@
package com.wasteinformationserver.website.datarequests.login;
import com.wasteinformationserver.basicutils.Log;
import com.wasteinformationserver.db.JDCB;
import com.wasteinformationserver.website.HttpTools;
import com.wasteinformationserver.website.basicrequest.PostRequest;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class LoginRequest extends PostRequest {
@Override
public String request(HashMap<String, String> params) {
Log.message("new login request");
String password = params.get("password");
String username = params.get("username");
ResultSet s = new JDCB("users", "kOpaIJUjkgb9ur6S", "wasteinformation").executeQuery("select * from user where username ='" + username + "'");
String response = "{\"accept\": false}";
try {
s.last();
if (s.getRow() == 1) {
//success
if (HttpTools.StringToMD5(password).equals(s.getString("password"))) {
Log.debug("login success");
LoginState.getObject().logIn();
LoginState.getObject().setAccountData(username,"","","");
response = "{\"accept\": true}";
} else {
Log.debug("wrong password");
}
} else if (s.getRow() == 0) {
//user not found
Log.debug("user not found");
} else {
//internal error two users with same name...?
}
Log.debug("rowcount: " + s.getRow());
} catch (SQLException e) {
e.printStackTrace();
}
return response;
}
}