Exemple #1
0
        protected async Task AuthenticateAsync(string userName, string password, HttpAuthenticationContext context,
                                               CancellationToken cancellationToken)
        {
            if (userName == null || password == null)
            {
                context.ErrorResult = new AuthenticationFailureResult("Null authentication field.", context.Request);
                return;
            }

            Tuple <string, string, IList <string> > result = await Api.AuthenticateDeviceAsync(userName, password);

            if (result == null)
            {
                //Log.AuthenticateDevice(userName, password, false);
                context.ErrorResult = new AuthenticationFailureResult("Bad credentials.", context.Request);
                return;
            }
            else
            {
                context.Principal = OverlordIdentity.InitializeDevicePrincipal(result.Item1,
                                                                               result.Item2, result.Item3);
                //Log.AuthenticateDevice(userName, password, true);
                return;
            }
        }