public void Run()
        {
            IAuthenticationFactory factory        = new FaceAuthenticationFactory();
            IAuthentication        authentication = factory.Create();

            authentication.Authentication();
        }
Example #2
0
 public ActionResult Login(Account account)
 {
     _authentication.httpContext = System.Web.HttpContext.Current;
     if (!_authentication.Authentication(account))
     {
         account.Password = null;
         return(View(account));
     }
     return(RedirectToAction("Home", "Start"));
 }
        public bool Login(IAuthentication employee, string password)
        {
            bool authenticatedUser = employee.Authentication(password);

            if (authenticatedUser)
            {
                Console.WriteLine("Login Realizado com sucesso!");
                return(true);
            }
            else
            {
                Console.WriteLine("Autenticação invalida");
                return(true);
            }
        }
Example #4
0
        public bool Login(IAuthentication employee, string password)
        {
            bool authenticationUser = employee.Authentication(password);

            if (authenticationUser)
            {
                Console.WriteLine("Successfully authenticated");
                return(true);
            }
            else
            {
                Console.WriteLine("Not authenticated");
                return(false);
            }
        }
Example #5
0
        public bool Login(IAuthentication employee, string password)
        {
            bool userAuthenticated = employee.Authentication(password);

            if (userAuthenticated)
            {
                Console.WriteLine("Realizado com sucesso!");
                return(true);
            }
            else
            {
                Console.WriteLine("Realizado com erro!");
                return(false);
            }
        }
        public HttpResponseMessage Post(LoginViewModel login)
        {
            var encPass = AlgorithmsAll.Sha256Algorithm.GetMD5Hash(login.Password);
            var usr     = authentication.Authentication(login.Username, encPass);

            if (usr != null)
            {
                login.Email = usr.Email;
                login.Type  = usr.UserType;
                string auth = login.Username + "|" + login.Email + "|" + login.Type;



                HttpCookie toolCookie = new HttpCookie("navInfo");
                toolCookie["UserName"] = login.Username;
                toolCookie["Email"]    = login.Email;
                toolCookie["Type"]     = login.Type.ToString();
                toolCookie["Created"]  = usr.RequestCreated.ToString();
                toolCookie.Expires     = DateTime.Now.AddHours(24);
                var respo = HttpContext.Current.Response;

                respo.Cookies.Add(toolCookie);
                string username = login.Username;
                string password = login.Password;



                string roles = "";
                if (usr.UserType == 2)
                {
                    roles = "Admin";
                }
                else
                {
                    roles = "User";
                }
                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1,
                    username + ":" + login.Email + ":" + login.Type + ":" + usr.Id, //user id
                    DateTime.Now,
                    DateTime.Now.AddYears(1),                                       // expiry
                    false,                                                          //do not remember
                    roles,
                    "/");

                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                                   FormsAuthentication.Encrypt(authTicket));
                respo.Cookies.Add(cookie);

                string     svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + login.Email + ":" + login.Type + ":" + usr.Id));
                HttpCookie sessionCookie  = new HttpCookie("SessionId");
                sessionCookie.Value   = svcCredentials;
                sessionCookie.Expires = DateTime.Now.AddYears(1);
                respo.Cookies.Add(sessionCookie);

                var response = Request.CreateResponse(HttpStatusCode.Created, login);
                return(response);
            }
            else
            {
                ModelState.AddModelError("", "Neteisingas vartotojo vardas arba slaptažodis");
                var response = Request.CreateResponse(HttpStatusCode.BadRequest, login);
                return(response);
            }
        }