public IActionResult SignInSubmit() { TempData["message"] = ""; if (String.IsNullOrEmpty(HttpContext.Request.Form["email"].ToString()) || String.IsNullOrEmpty(HttpContext.Request.Form["passwd"].ToString())) { TempData["message"] = "Please fill all the blanks"; return(RedirectToAction("Index", "SignIn")); } String group = DbUsers.SignInFunc(HttpContext.Request.Form["email"].ToString(), HttpContext.Request.Form["passwd"].ToString(), _context); if (group == "undefined") { TempData["message"] = "Bad User name or Password"; return(RedirectToAction("Index", "SignIn")); } if (group == "Employee") { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); obj["group"] = "Employee"; obj["email"] = HttpContext.Request.Form["email"].ToString(); TempData["client"] = obj.ToString(); return(RedirectToAction("Index", "Employee")); } if (group == "Manager") { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); obj["group"] = "Manager"; obj["email"] = HttpContext.Request.Form["email"].ToString(); TempData["client"] = obj.ToString(); return(RedirectToAction("Index", "Manager")); } return(RedirectToAction("Index", "Home")); }
/// <summary> /// Initializes a new instance of the <see cref="AccountDateLimit"/> class. /// </summary> /// <param name="sst">The main class.</param> public AccountDateLimit(SynServerTool sst) { _sst = sst; _userDb = new DbUsers(); _configHandler = new ConfigHandler(); LoadConfig(); }
public async Task <ActionResult <DbUsers> > PostDbUsers(DbUsers dbUsers) { _context.Users.Add(dbUsers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDbUsers", new { id = dbUsers.Id }, dbUsers)); }
/// <summary> /// Initializes a new instance of the <see cref="EloLimit"/> class. /// </summary> /// <param name="sst">The main class.</param> public EloLimit(SynServerTool sst) { _sst = sst; _configHandler = new ConfigHandler(); _users = new DbUsers(); LoadConfig(); }
public async Task <IActionResult> PutDbUsers(int id, DbUsers dbUsers) { if (id != dbUsers.Id) { return(BadRequest()); } _context.Entry(dbUsers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DbUsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Automatically gives operator status using QL's internal op system to all of the server's /// current players who are SST users with userlevel Admin or higher. /// </summary> public async Task AutoOpActiveAdmins() { if (!_sst.IsMonitoringServer) { return; } var cfgHandler = new ConfigHandler(); var cfg = cfgHandler.ReadConfiguration(); if (!cfg.CoreOptions.autoOpAdmins) { return; } var userDb = new DbUsers(); var allUsers = userDb.GetAllUsers(); foreach (var u in allUsers.Where(u => _sst.ServerInfo.CurrentPlayers.ContainsKey(u.Name))) { if (u.AccessLevel <= UserLevel.SuperUser) { continue; } var id = GetPlayerId(u.Name); if (id == -1) { continue; } await _sst.QlCommands.SendToQlAsync(string.Format("op {0}", id), false); Log.Write(string.Format("Auto-opping {0} (user level: {1})", u.Name, u.AccessLevel), _logClassType, _logPrefix); } }
//returns "MODEL.User" object if successful/found //returns "null" if not internal User findUserByEmail(string email) { int result = (int)CODE.MINUS_ONE; User user = null; //validate email if ( result == (int)CODE.ZERO || string.IsNullOrWhiteSpace(email) || !Validate.hasMinLength(email, 5) || !Validate.hasMaxLength(email, 50) || !email.Contains("@") ) { result = (int)CODE.ZERO; } if (result != (int)CODE.ZERO)//safe to proceed { IUsers _DbUsers = new DbUsers(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { user = _DbUsers.findUserByEmail(email); trScope.Complete(); } } catch (TransactionAbortedException taEx) { result = (int)CODE.ZERO; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { result = (int)CODE.ZERO; Log.Add(aEx.ToString()); } catch (Exception ex) { result = (int)CODE.ZERO; Log.Add(ex.ToString()); } } else { result = (int)CODE.ZERO; } if (result == (int)CODE.ZERO || user == null) { return(null); } else { return(user); } }
//returns "MODEL.User" object if successful/found //returns "null" if not internal User findUserByUserName(string userName) { int result = (int)CODE.MINUS_ONE; User user = null; //validate userName if ( result == (int)CODE.ZERO || string.IsNullOrWhiteSpace(userName) || !Validate.isAlphaNumericWithUnderscore(userName) || !Validate.hasMinLength(userName, 5) || !Validate.hasMaxLength(userName, 15) ) { result = (int)CODE.ZERO; } if (result != (int)CODE.ZERO)//safe to proceed { IUsers _DbUsers = new DbUsers(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { user = _DbUsers.findUserByUserName(userName); trScope.Complete(); } } catch (TransactionAbortedException taEx) { result = (int)CODE.ZERO; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { result = (int)CODE.ZERO; Log.Add(aEx.ToString()); } catch (Exception ex) { result = (int)CODE.ZERO; Log.Add(ex.ToString()); } } else { result = (int)CODE.ZERO; } if (result == (int)CODE.ZERO || user == null) { return(null); } else { return(user); } }
/// <summary> /// Initializes a new instance of the <see cref="EarlyQuitHandler"/> class. /// </summary> public EarlyQuitHandler(SynServerTool sst) { _sst = sst; _quitsDb = new DbQuits(); _usersDb = new DbUsers(); _bansDb = new DbBans(); GetConfigData(); }
/// <summary> /// Initializes a new instance of the <see cref="CommandProcessor"/> class. /// </summary> /// <param name="sst">The main class.</param> public CommandProcessor(SynServerTool sst) { _sst = sst; _users = new DbUsers(); _cmdList = new CommandList(_sst); _cfgHandler = new ConfigHandler(); _playerCommandTime = new Dictionary <string, DateTime>(); }
//returns "MODEL.User" object if successful/found //returns "null" if not internal User findUserByUserId(int userId) { int result = (int)CODE.MINUS_ONE; User user = null; //validate userId if ( result == (int)CODE.ZERO || string.IsNullOrWhiteSpace(userId.ToString()) || !Validate.isAllNumbers(userId.ToString()) || !Validate.integerIsBiggerThan(userId, (int)CODE.TRANSLATO_DATABASE_SEED - 1) ) { result = (int)CODE.ZERO; } if (result != (int)CODE.ZERO)//safe to proceed { IUsers _DbUsers = new DbUsers(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { user = _DbUsers.findUserByUserId(userId); trScope.Complete(); } } catch (TransactionAbortedException taEx) { result = (int)CODE.ZERO; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { result = (int)CODE.ZERO; Log.Add(aEx.ToString()); } catch (Exception ex) { result = (int)CODE.ZERO; Log.Add(ex.ToString()); } } else { result = (int)CODE.ZERO; } if (result == (int)CODE.ZERO || user == null) { return(null); } else { return(user); } }
/// <summary> /// Initializes a new instance of the <see cref="SuggestTeamsCmd"/> class. /// </summary> /// <param name="sst">The main class.</param> public SuggestTeamsCmd(SynServerTool sst) { QlMinArgs = 0; _sst = sst; _qlrHelper = new QlRanksHelper(); _teamBalancer = new TeamBalancer(); _users = new DbUsers(); _balancedRedTeam = new List <PlayerInfo>(); _balancedBlueTeam = new List <PlayerInfo>(); _suggestionTimer = new Timer(); }
public IActionResult PushCalendar() { if (String.IsNullOrEmpty(HttpContext.Request.Form["selecteddatestart"].ToString()) || String.IsNullOrEmpty(HttpContext.Request.Form["selecteddateend"].ToString()) || String.IsNullOrEmpty(HttpContext.Request.Form["reason"].ToString())) { TempData["message"] = "Please fill all the blanks"; return(RedirectToAction("Index", "Employee")); } if ((DbUsers.PostDayOff(HttpContext.Request.Form["selecteddatestart"].ToString(), HttpContext.Request.Form["selecteddateend"].ToString(), HttpContext.Request.Form["reason"].ToString(), (JObject.Parse(TempData.Peek("client").ToString())["email"]).ToString(), _context)) == false) { System.Diagnostics.Debug.WriteLine("ERROR : can't post the day off"); } return(RedirectToAction("Index", "Employee")); }
public IActionResult RequirementsList() { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); System.Diagnostics.Debug.WriteLine(TempData.Peek("client").ToString()); if (obj["group"].ToString() != "Employee") { return(RedirectToAction("Index", "Home")); } JArray array = DbUsers.getRequirementsListFromUser((JObject.Parse(TempData.Peek("client").ToString())["email"]).ToString(), _context); ViewData["list"] = array; return(View("RequirementsList")); }
public IActionResult Index() { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); System.Diagnostics.Debug.WriteLine(TempData.Peek("client").ToString()); if (obj["group"].ToString() != "Manager") { return(RedirectToAction("Index", "Home")); } JArray array = DbUsers.getAllRequirementsList(_context); ViewData["list"] = array; return(View()); }
public IActionResult RemoveItem(String Id) { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); System.Diagnostics.Debug.WriteLine(TempData.Peek("client").ToString()); if (obj["group"].ToString() != "Employee") { return(RedirectToAction("Index", "Home")); } if (DbUsers.removeOneItemFromList((JObject.Parse(TempData.Peek("client").ToString())["email"]).ToString(), Id, _context) == false) { System.Diagnostics.Debug.WriteLine("Error : can't remove Item"); } return(RedirectToAction("RequirementsList", "Employee")); }
/// <summary> /// Executes the specified command asynchronously. /// </summary> /// <param name="c">The command argument information.</param> /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns> public async Task <bool> ExecAsync(Cmd c) { var userDb = new DbUsers(); var allUsers = userDb.GetAllUsers(); var sb = new StringBuilder(); foreach (var u in allUsers.Where(u => _sst.ServerInfo.CurrentPlayers.ContainsKey(u.Name))) { sb.Append(string.Format("^7{0} (^5{1}^7), ", u.Name, u.AccessLevel)); } StatusMessage = string.Format("^5Access levels: {0}", sb.ToString().TrimEnd(',', ' ')); await SendServerSay(c, StatusMessage); return(true); }
public IActionResult changeStateRequest() { JObject obj = JObject.Parse(TempData.Peek("client").ToString()); System.Diagnostics.Debug.WriteLine(TempData.Peek("client").ToString()); if (obj["group"].ToString() != "Manager") { return(RedirectToAction("Index", "Home")); } if (!DbUsers.changeStateOneRequest(HttpContext.Request.Form["emailUser"].ToString(), HttpContext.Request.Form["idRequest"].ToString(), HttpContext.Request.Form["newState"].ToString(), _context)) { System.Diagnostics.Debug.WriteLine("ERROR : can't change state request"); } return(RedirectToAction("Index", "Manager")); }
public static bool RegistrationNewUser(string _login, string _password, string _email) { DbUsers Users = new DbUsers(); if (!Users.Items.Exists(x => x.Login == _login)) { WorkinhWithUserMethods m = new WorkinhWithUserMethods(); List <User> users = Users.Items; Users.Add(new User { Login = _login, Password = GetHash(_password), Email = _email, FavouriteStations = new List <FavouriteStation>() }); return(true); } else { return(false); } }
/// <summary> /// Executes the specified command asynchronously. /// </summary> /// <param name="c">The command argument information.</param> /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns> public async Task <bool> ExecAsync(Cmd c) { var userDb = new DbUsers(); var senderLevel = userDb.GetUserLevel(c.FromUser); var senderLevelName = Enum.GetName(typeof(UserLevel), senderLevel); var cmds = new StringBuilder(); foreach (var cmd in _sst.CommandProcessor.Commands.Where(cmd => cmd.Value.UserLevel <= senderLevel)) { cmds.Append(string.Format("^3{0}^5{1} ", CommandList.GameCommandPrefix, cmd.Key)); } StatusMessage = string.Format( "^7Your user level - ^3{0}^7 - has access to these commands: {1}," + " ^7More help @ ^3sst.syncore.org^7, or ^3#sst^7 on QuakeNet.", (senderLevelName ?? "NONE"), cmds.ToString().TrimEnd(' ')); await SendServerTell(c, StatusMessage); return(true); }
public IActionResult SignUpSubmit() { if (String.IsNullOrEmpty(HttpContext.Request.Form["email"].ToString()) || String.IsNullOrEmpty(HttpContext.Request.Form["passwd"].ToString()) && String.IsNullOrEmpty(HttpContext.Request.Form["confirmpasswd"].ToString())) { TempData["message"] = "Please fill all the blanks"; return(RedirectToAction("Index", "SignUp")); } if (HttpContext.Request.Form["passwd"].ToString() != HttpContext.Request.Form["confirmpasswd"].ToString()) { TempData["message"] = "Password and Confirm Password must be the same"; return(RedirectToAction("Index", "SignUp")); } if (DbUsers.SignUpFunc(HttpContext.Request.Form["email"].ToString(), HttpContext.Request.Form["passwd"].ToString(), HttpContext.Request.Form["group"].ToString(), _context) == false) { TempData["message"] = "User already exist"; return(RedirectToAction("Index", "SignUp")); } TempData["message"] = ""; return(RedirectToAction("Index", "SignIn")); }
public ActionResult Login(LoggedinInfo user) { DbUsers dbuser = new DbUsers(); dbuser.UserName = user.UserName; if (ModelState.IsValid) { bool output = false; DatabaseConnection dbconnect = new DatabaseConnection(); DbUsers resultuser = dbconnect.UserLogin(dbuser); try { output = Crypto.VerifyHashedPassword(resultuser.Password, user.Password); } catch { output = false; } if (output) { UserInfo userModel = new UserInfo() { UserId = resultuser.UserId, FirstName = resultuser.FirstName, LastName = resultuser.LastName, EmailID = resultuser.EmailID, PhoneNumber = resultuser.PhoneNumber, UserName = resultuser.UserName, Password = resultuser.Password }; Session["User"] = userModel; return(RedirectToAction("UserAccount")); } else { ModelState.AddModelError("CustomError", "Incorrect Username and password"); return(View()); } } return(View()); }
/// <summary> /// Automatically gives operator status using QL's internal op system to the specified /// player who is currently on the server and is an SST user with userlevel Admin or higher. /// </summary> public async Task AutoOpActiveAdmin(string player) { if (!_sst.IsMonitoringServer) { return; } var cfgHandler = new ConfigHandler(); var cfg = cfgHandler.ReadConfiguration(); if (!cfg.CoreOptions.autoOpAdmins) { return; } var userDb = new DbUsers(); var userLevel = userDb.GetUserLevel(player); if (userLevel <= UserLevel.SuperUser) { return; } if (!_sst.ServerInfo.CurrentPlayers.ContainsKey(player)) { return; } var id = GetPlayerId(player); if (id == -1) { return; } await _sst.QlCommands.SendToQlAsync(string.Format("op {0}", id), false); Log.Write(string.Format("Auto-opping {0} (user level: {1})", player, userLevel), _logClassType, _logPrefix); }
public ActionResult Registration(UserInfo user) { if (ModelState.IsValid) { var hash = Crypto.HashPassword(user.Password); DbUsers dbuser = new DbUsers(); dbuser.FirstName = user.FirstName; dbuser.LastName = user.LastName; dbuser.EmailID = user.EmailID; dbuser.Password = hash; dbuser.PhoneNumber = user.PhoneNumber; dbuser.UserName = user.UserName; DatabaseConnection dbconnect = new DatabaseConnection(); ReturnCode.result result = dbconnect.UserRegistration(dbuser); if (result.Equals(ReturnCode.result.fail)) { ModelState.AddModelError("CustomError", "Registration not Successful.Please try later"); return(View()); } else if (result.Equals(ReturnCode.result.userexist)) { ModelState.AddModelError("CustomError", "EmailID/UserName already exist"); return(View()); } else if (result.Equals(ReturnCode.result.success)) { ViewBag.Message = "Registration successful.Please login"; return(RedirectToAction("Login")); } } return(View(user)); }
public ActionResult ForgetPassword(LoggedinInfo user) { var hash = Crypto.HashPassword(user.Password); DbUsers dbuser = new DbUsers(); dbuser.UserName = user.UserName; dbuser.Password = hash; if (ModelState.IsValid) { DatabaseConnection dbconnect = new DatabaseConnection(); ReturnCode.result result = dbconnect.changePassword(dbuser); if (result.Equals(ReturnCode.result.success)) { TempData["Message"] = "Password has been changed.Please Login"; return(RedirectToAction("Login")); } else { ModelState.AddModelError("CustomError", "Password has not been changed"); return(View()); } } return(View()); }
/// <summary> /// Initializes a new instance of the <see cref="AddUserCmd"/> class. /// </summary> /// <param name="sst">The main class.</param> public AddUserCmd(SynServerTool sst) { _sst = sst; _users = new DbUsers(); }
public PickupCmd(SynServerTool sst) { _sst = sst; _userDb = new DbUsers(); }
/// <summary> /// Initializes a new instance of the <see cref="VoteHandler"/> class. /// </summary> /// <param name="sst">The main class.</param> public VoteHandler(SynServerTool sst) { _sst = sst; _users = new DbUsers(); }
public UserRepository(DbUsers dbUsers) { this.dbUsers = dbUsers; var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance; }
public UoWUsers() { NinjectKernel.NinjectContext.SeUp(new NInjectConfigs.NInjectCofigUser()); dbUsers = NinjectKernel.NinjectContext.Get <DbUsers>(); }