Exemple #1
0
        public IActionResult Login([FromBody] Admin adm)
        {
            try
            {
                string PASSWORD = "";

                try
                {
                    PASSWORD = _repository.Login(adm.EMAIL).PASSWORD;
                    if (PASSWORD == "" || PASSWORD == string.Empty)
                    {
                        return(StatusCode(404, "Account not found"));
                    }
                }
                catch (Exception)
                {
                    return(StatusCode(404, "Account not found"));
                }


                if (PASSWORD == adm.PASSWORD)
                {
                    NotifyAdmin(_repository.SearchAdmin(adm.CPF), "We inform that someone just logged on your account!");
                    return(Ok("Welcome"));
                }
                else
                {
                    return(StatusCode(400, "Invalid Credentials"));
                }
            }
            catch (Exception)
            {
                return(StatusCode(500, "We had an unknown error"));
            }
        }
Exemple #2
0
        public async Task <IActionResult> Post([FromBody] AdminModel admin)
        {
            var login = admins.Login(admin);

            if (login == null)
            {
                return(Ok(new{ error = true, data = "" }));
            }
            return(Ok(new{ error = false, data = login }));
        }
Exemple #3
0
        public ActionResult login(AdminModel admin)
        {
            var login = admins.Login(admin);

            if (login == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            HttpContext.Session.SetString(SessionName, login.name);
            HttpContext.Session.SetInt32(SessionId, login.id);
            // ViewBag.Name = HttpContext.Session.GetString(SessionName);
            // ViewBag.Age = HttpContext.Session.GetInt32(SessionId);

            return(RedirectToAction("Index", "WorkShopRecordsWeb"));
        }