public IHttpActionResult AuthenticateSellffUserInfo([FromBody] ProfileInfoBO objAuthenticationBO)
        {
            var response = objSellffDefaultService.AuthenticateSellffUser(objAuthenticationBO.UserName, objAuthenticationBO.Password);

            if (!string.IsNullOrEmpty(response.ErrorMessage))
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Unauthorized, response)));
            }
            else
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, response)));
            }
        }
Ejemplo n.º 2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            SellffDefaultService objSellffDefaultService = new SellffDefaultService();
            var user = objSellffDefaultService.AuthenticateSellffUser(context.UserName, context.Password);

            if (string.IsNullOrWhiteSpace(context.UserName) || string.IsNullOrWhiteSpace(context.Password) ||
                user == null)
            {
                context.Rejected();
                context.SetError("invalid_grant", "The user name or password is incorrect.");
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            identity.AddClaim(new Claim("email", user.Email));
            identity.AddClaim(new Claim("username", user.DisplayName));
            context.Validated(identity);
        }