public ActionResult AdminReg(RegisterViewModel newUser, string RetypePassword) { if (newUser.Password == RetypePassword) { var res = UserAccount.Create(newUser.UserName, newUser.Password, "admin"); if (res != null) { var newAdmin = new AdminReg(); newAdmin.FirstName = newUser.FirstName; newAdmin.LastName = newUser.LastName; newAdmin.UserName = newUser.UserName; newAdmin.Password = newUser.Password; _db.AdminRegs.Add(newAdmin); _db.SaveChanges(); ViewBag.message = "Registered Successfully!"; return(View()); } ViewBag.messages = "Registration Failed"; } else { ViewBag.messages = "Password not matched"; } return(View()); }
public async void ReloadAdmin(IPlayerSession player) { var data = await LoadAdminData(player); var curAdmin = _admins.GetValueOrDefault(player); if (data == null && curAdmin == null) { // Wasn't admin before or after. return; } if (data == null) { // No longer admin. _admins.Remove(player); _chat.DispatchServerMessage(player, Loc.GetString("You are no longer an admin.")); } else { var(aData, rankId, special) = data.Value; if (curAdmin == null) { // Now an admin. var reg = new AdminReg(player, aData) { IsSpecialLogin = special, RankId = rankId }; _admins.Add(player, reg); _chat.DispatchServerMessage(player, Loc.GetString("You are now an admin.")); } else { // Perms changed. curAdmin.IsSpecialLogin = special; curAdmin.RankId = rankId; curAdmin.Data = aData; } if (!player.ContentData() !.ExplicitlyDeadminned) { aData.Active = true; _chat.DispatchServerMessage(player, Loc.GetString("Your admin permissions have been updated.")); } } SendPermsChangedEvent(player); UpdateAdminStatus(player); }