public IHttpActionResult Post(UserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest("Invalid modelstate");
            }
            AuthRepository repo = new AuthRepository();
            var result =  repo.RegisterUser(Mapper.Map<UserModel>(model));

            return Ok(result);
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            AuthRepository userRepository = new AuthRepository();
            var result = await userRepository.FindUser(context.UserName, context.Password);

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Credentials", new[] { "true" });

            if (result == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));
            identity.AddClaim(new Claim("UserID", result.Id));


            context.Validated(identity);
        }