Example #1
0
        protected override AuthenticationResult Authenticate(UnitOfWork UoW, LoginParameters LoginParameters)
        {
            AuthenticationResult authenticationResult = new AuthenticationResult();

            try
            {
                PermissionPolicyUser User = UoW.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", LoginParameters.Username));

                if (User == null)
                {
                    authenticationResult.LastError = "User not found";
                    return(authenticationResult);
                }
                if (!User.ComparePassword(LoginParameters.Password))
                {
                    authenticationResult.LastError = "Password do not match";
                    return(authenticationResult);
                }

                authenticationResult.Authenticated = true;
                authenticationResult.UserId        = User.Oid.ToString();
                authenticationResult.Username      = User.UserName;
                return(authenticationResult);
            }
            catch (Exception exception)
            {
                authenticationResult.LastError = exception.Message;
                return(authenticationResult);
            }
        }
Example #2
0
        public override object Authenticate(IObjectSpace objectSpace)
        {
            PermissionPolicyUser result = null;
            string userName             = customLogonParameters.UserName;
            string password             = customLogonParameters.Password;

            result = objectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", userName));



            //TODO here you need to validate your user authentication
            //result = (PermissionPolicyUser)base.Authenticate(objectSpace);

            if (!result.ComparePassword(password))
            {
                throw new AuthenticationException("Error");
            }



            return(result);
        }