Ejemplo n.º 1
0
        protected override bool OnAuthorizeUser(string name, string password, HttpActionContext actionContext)
        {
            var provider = new TokenServices();

            if (provider != null)
            {
                Debug.WriteLine("Authenticating credentials - {0} {1}", name, password);
                ResponseWithToken token = provider.AuthenticateAsync(name, password).Result;
                Debug.WriteLine("Token - " + token);

                if (token != null)
                {
                    var basicAuthenticationIdentity = Thread.CurrentPrincipal.Identity as BasicAuthenticationIdentity;

                    if (basicAuthenticationIdentity != null)
                    {
                        basicAuthenticationIdentity.UserName = name;
                    }

                    return(true);
                }
            }

            return(false);
        }