public ActionResult Register() { if (UsersUtilities.GetLoggedUser() == null) { return(Redirect("~/User/Login")); } return(View()); }
public void ReturnedUserFromArrayOfUsersHasCorrectProperties_GivenName(string name) { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); UsersDTO retrievedUser = UsersUtilities.GetUserIfExists(bulkService.results, name); Assert.That(retrievedUser.username, Is.EqualTo("Bret")); Assert.That(retrievedUser.phone, Is.EqualTo("1-770-736-8031 x56442")); }
public ActionResult CheckOneServer(string IP) { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } return(Json(ServerUtilities.CheckServer(loggedUser, IP), JsonRequestBehavior.AllowGet)); }
public void LoginUser(string email, string password) { try { UsersUtilities.Login(email, password); } catch (Exception ex) { Email = email; Error = ex.Message; TryCookie(); throw; } }
public ActionResult ShowServers() { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } if (loggedUser.Servers.Count == 0) { return(RedirectToAction("Register")); } return(View(loggedUser.Servers)); }
public ActionResult CheckPort(int port, int server) { try { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } ServerUtilities.CheckPort(loggedUser, loggedUser.Servers.Where(i => i.Id == server).FirstOrDefault(), port); return(Json(new { Port = port, Status = "Aberta" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Port = port, Status = ex.Message }, JsonRequestBehavior.AllowGet)); } }
// // GET: /Reports/ public ActionResult ServerLog(int?Id) { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } ServerLogs logs = new ServerLogs(loggedUser); if (Id != null) { logs.SelectServer(Id.Value); } return(View(logs)); }
public ActionResult AddPorts(int server, int port) { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } try { new AddPort(loggedUser, server, port); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View("ShowServers", loggedUser.Servers)); }
public async Task <ActionResult> Register(string name, string ip, string contactEmail, Times verificationTime) { var loggedUser = UsersUtilities.GetLoggedUser(); if (loggedUser == null) { return(Redirect("~/User/Login")); } RegisterServer ServerToRegister = new RegisterServer(); try { ServerToRegister.Setup(name, ip, contactEmail, verificationTime, loggedUser); RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper(); if (String.IsNullOrEmpty(recaptchaHelper.Response)) { throw new CustomException.EmptyRecaptcha(); } RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync(); if (recaptchaResult != RecaptchaVerificationResult.Success) { throw new CustomException.Recaptcha(); } ServerToRegister.Save(); return(View(ServerToRegister)); } catch (Exception ex) { if (ex is CustomException.EmptyRecaptcha || ex is CustomException.Recaptcha) { ServerToRegister.Error = ex.Message; } return(View(ServerToRegister)); } }
public void CheckUserExistsInArrayOfUsers_GivenName(string name) { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); Assert.That(UsersUtilities.VerifyUserExistsByName(bulkService.results, name)); }
public void CheckCorrectNumberOfUsersReturnedFromGetRequest_WithNoIDSpecified() { bulkService = new TypecodeAPIServices <UsersDTO[]>(new UsersAPIRunner( new RestSharp.RestClient(TypecodeReader.BaseUrl), "users")); Assert.That(UsersUtilities.FindNumberOfUsers(bulkService.results), Is.EqualTo(10)); }
public ActionResult Logoff() { UsersUtilities.Logoff(); return(Redirect("/home/index")); }