Beispiel #1
0
        public IHttpActionResult Authenticate(LoginRequest login)
        {
            if (login == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            if (Membership.ValidateUser(login.Username, login.Password))
            {
                var token = TokenGenerator.GenerateTokenJwt(login.Username);
                return(Ok(token));
            }
            else
            {
                return(Unauthorized());
            }
        }
Beispiel #2
0
        public IHttpActionResult Authenticate(BOUser login)
        {
            if (login == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            //TODO: Validate credentials Correctly, this code is only for demo !!
            BusinessResult result = CoreFactory.Instance.UserLogin(login);

            if (result.Success)
            {
                var token = TokenGenerator.GenerateTokenJwt(login.Email);
                return(Ok(token));
            }
            else
            {
                return(Unauthorized());
            }
        }