Пример #1
0
        public IHttpActionResult Authenticate([FromBody] LoginModel login)
        {
            bool isUsernamePasswordValid = false;

            if (login != null)
            {
                isUsernamePasswordValid = login.Password == "admin" ? true : false;
            }

            if (isUsernamePasswordValid)
            {
                string token = Jwt_Authentication.GenerateToken(login.Username);

                return(Ok <string>(token));
            }
            else
            {
                return(BadRequest("Login failed, invalid Username or Password."));
            }
        }
        public IHttpActionResult Authenticate([FromBody] UserLogin login)
        {
            bool     isUsernamePasswordValid = false;
            Customer logedUser = new Customer();

            if (login != null)
            {
                logedUser = db.customers.SingleOrDefault(p => p.cust_MailID == login.userEmail) as Customer;
                isUsernamePasswordValid = logedUser != null ? true : false;
            }
            if (isUsernamePasswordValid)
            {
                string token = Jwt_Authentication.GenerateToken(logedUser);

                return(Ok(token));
            }
            else
            {
                return(BadRequest("Login failed, invalid Username or Password."));
            }
        }