示例#1
0
        public ActionResult Register()
        {
            if (UsersUtilities.GetLoggedUser() == null)
            {
                return(Redirect("~/User/Login"));
            }

            return(View());
        }
示例#2
0
        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"));
        }
示例#3
0
        public ActionResult CheckOneServer(string IP)
        {
            var loggedUser = UsersUtilities.GetLoggedUser();

            if (loggedUser == null)
            {
                return(Redirect("~/User/Login"));
            }
            return(Json(ServerUtilities.CheckServer(loggedUser, IP), JsonRequestBehavior.AllowGet));
        }
示例#4
0
文件: Login.cs 项目: LoweTI/Gragas
 public void LoginUser(string email, string password)
 {
     try
     {
         UsersUtilities.Login(email, password);
     }
     catch (Exception ex)
     {
         Email = email;
         Error = ex.Message;
         TryCookie();
         throw;
     }
 }
示例#5
0
        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));
        }
示例#6
0
 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));
     }
 }
示例#7
0
        //
        // 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));
        }
示例#8
0
        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));
        }
示例#9
0
        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));
            }
        }
示例#10
0
 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));
 }
示例#11
0
 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));
 }
示例#12
0
 public ActionResult Logoff()
 {
     UsersUtilities.Logoff();
     return(Redirect("/home/index"));
 }