コード例 #1
0
        // Try To Login As Admin User.
        public bool TryAdminLogin(string userName, string password, out LoginToken <Administrator> token)
        {
            token = null;
            // Default Admin.
            if (userName.ToUpper() == FlyingCenterConfig.ADMIN_NAME)
            {
                if (password == FlyingCenterConfig.ADMIN_PASSWORD)
                {
                    token = new LoginToken <Administrator> {
                        User = new Administrator {
                            Id = 0, User_Name = FlyingCenterConfig.ADMIN_NAME, Password = FlyingCenterConfig.ADMIN_PASSWORD
                        }
                    };
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException("Your Password Isn't Match To Your UserName!");
                }
            }
            //DAO Admin.
            Administrator admin = _administratorDAO.GetByUserName(userName);

            if (admin.User_Name.ToUpper() == userName.ToUpper())
            {
                if (admin.Password.ToUpper() == password.ToUpper())
                {
                    token = new LoginToken <Administrator> {
                        User = admin
                    };
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException("Your Password Isn't Match To Your UserName!");
                }
            }
            return(false);
        }
コード例 #2
0
        public bool TryLogin(string userName, string password, out ILogin token, out FacadeBase facade)
        {
            token  = null;
            facade = new AnonymousUserFacade();

            // Default Admin.
            if (userName.ToUpper() == FlyingCenterConfig.ADMIN_NAME.ToUpper())
            {
                if (password.ToUpper() == FlyingCenterConfig.ADMIN_PASSWORD.ToUpper())
                {
                    token = new LoginToken <Administrator>
                    {
                        User = new Administrator
                               (
                            0, //Admin Number
                            0, //Id
                            FlyingCenterConfig.ADMIN_NAME,
                            FlyingCenterConfig.ADMIN_PASSWORD
                               )
                    };
                    facade = new LoggedInAdministratorFacade();
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException("Sorry, But Your Password Isn't Match To Your User Name.");
                }
            }

            // DAO Users.
            User user = _userDAO.GetUserByUserName(userName);

            if (user != null)
            {
                if (password.ToUpper() == user.Password.ToUpper())
                {
                    switch (user.MyType)
                    {
                    case UserType.Administrator:
                    {
                        Administrator admin = _administratorDAO.GetById(user.Id);
                        token = new LoginToken <Administrator>
                        {
                            User = new Administrator
                                   (
                                admin.Admin_Number,
                                user.Id,
                                user.UserName,
                                user.Password
                                   )
                        };
                        facade = new LoggedInAdministratorFacade();
                        break;
                    }

                    case UserType.Airline:
                    {
                        AirlineCompany airline = _airlineDAO.GetById(user.Id);
                        token = new LoginToken <AirlineCompany>
                        {
                            User = new AirlineCompany
                                   (
                                airline.Airline_Number,
                                user.Id,
                                user.UserName,
                                user.Password,
                                airline.Airline_Name,
                                airline.Country_Code
                                   )
                        };
                        facade = new LoggedInAirlineFacade();
                        break;
                    }

                    case UserType.Customer:
                    {
                        Customer customer = _customerDAO.GetById(user.Id);
                        token = new LoginToken <Customer>
                        {
                            User = new Customer
                                   (
                                customer.Customer_Number,
                                user.Id,
                                user.UserName,
                                user.Password,
                                customer.First_Name,
                                customer.Last_Name,
                                customer.Address,
                                customer.Phone_No,
                                customer.Credit_Card_Number
                                   )
                        };
                        facade = new LoggedInCustomerFacade();
                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }
                    return(true);
                }
                else
                {
                    throw new WrongPasswordException("Sorry, But Your Password Is Not Match To Your User Name.");
                }
            }

            return(false);
        }