public static bool RegisterWithoutEmail(string username, string password) { // CREATE TABLE earthfusion_users( // user_id NUMBER, // user_name VARCHAR2(50), // user_email VARCHAR2(50), // user_password_hashed VARCHAR2(66), // user_status VARCHAR2(50), // user_role VARCHAR2(50), // PRIMARY KEY(user_id) // ); // table structure: // user_id: uuid. This is the unique identification of an user. // user_name: username/nickname // user_email: user's email // user_password_hashed: hashed password. SHA256 only. // user_status: is the user enabled? "enabled"/"disabled" // user_role: administrator/user string oracleSpatialAdminUsername = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_USERNAME"]; string oracleSpatialAdminPassword = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_PASSWORD"]; OracleConnection conn = OracleHelpers.GetOracleConnection(oracleSpatialAdminUsername, oracleSpatialAdminPassword, false); // currently the frontend register without email address string emailAddress = "*****@*****.**"; return(CreateUserRow(conn, username, emailAddress, password)); }
public static UserInformation Login(string username, string password) { string oracleUsername = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_DB_USERNAME"]; string oraclePassword = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_DB_PASSWORD"]; OracleConnection conn = OracleHelpers.GetOracleConnection(oracleUsername, oraclePassword, false); // Get user information List <UserInformation> selectedResult = GetUserInformation(conn, username); if (selectedResult.Count < 1) { Logging.Warning("EarthFusion.SessionHelpers.Login", "No matching username in raw data"); return(null); } string userPasswordHashed = GenericHelpers.ComputeSha256Hash(password); Logging.Info("EarthFusion.SessionHelpers.Login", "request has a hashed password of " + userPasswordHashed); foreach (UserInformation userInformation in selectedResult) { Logging.Info("EarthFusion.SessionHelpers.Login", "comparing user with uuid " + userInformation.userId.ToString()); Logging.Info("EarthFusion.SessionHelpers.Login", "This user has a hashed password of " + userInformation.userPasswordHashed); if (userPasswordHashed == userInformation.userPasswordHashed) { Logging.Info("EarthFusion.SessionHelpers.Login", "uuid " + userInformation.userId.ToString() + " seems good!"); return(userInformation); } } return(null); }
public static UserInformation Validate(string sessionId) { string oracleUsername = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_DB_USERNAME"]; string oraclePassword = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_DB_PASSWORD"]; OracleConnection conn = OracleHelpers.GetOracleConnection(oracleUsername, oraclePassword, false); return(ValidateSession(conn, sessionId)); }
public BussinessDistrictReport GetBussinessDistricReportByReportID(string sessionId, int reportId) { UserInformation user = GetSession(sessionId).userInformation; if (user == null) { return(null); } BussinessDistrictReport report = new BussinessDistrictReport(); string oracleSpatialAdminUsername = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_USERNAME"]; string oracleSpatialAdminPassword = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_PASSWORD"]; OracleConnection conn = OracleHelpers.GetOracleConnection(oracleSpatialAdminUsername, oracleSpatialAdminPassword, false); string QueryString = ("select * from nemo.BussinessDistricReport where user_id=" + user.userId).ToString(); Logging.Info("GetBussinessDistricReportByReportID", "Constructed query: " + QueryString); // constructs command from string OracleCommand command = new OracleCommand(QueryString, conn); // open db connection conn.Open(); // then, executes the data reader OracleDataReader reader = command.ExecuteReader(); if (reader.RowSize == 0) { return(null); } try { /* * * CREATE TABLE nemo.BussinessDistricReport * ( * user_id int, * bd_report_id int, * bd_report_log float, * bd_report_lat float, * bd_report_time date, * bd_competitiveness int, * bd_traffic_accessibility int, * PRIMARY KEY(bd_report_id) * * ) */ while (reader.Read()) { report.userId = reader.GetInt32(0); report.reportId = reader.GetInt32(1); report.longitude = reader.GetFloat(2); report.latitude = reader.GetFloat(3); report.date = reader.GetDateTime(4); report.competitiveness = reader.GetInt32(5); report.trafficAccessibility = reader.GetInt32(6); } } finally { // always call Close when done reading. reader.Close(); } conn.Close(); return(report); }