src/com/vehiclerental/presentationLayer/headOffice/BaseHeadOfficeController.java
/**
     * Apply authentication process to given email and password
     * If required, the user will also be required to be a staff user
     *
     * @param email the user email
     * @param password the user password
     * @param requireStaffAccount true if requires a staff account
     * @return the identified user
     * @throws NotAuthorizedException if not authorized or authenticated
     */
Apply authentication process to given email and password
If required, the user will also be required to be a staff user


Apply authentication process to given email and password If required the user will also be required to be a staff user
protected static User doAuthentication(String email, String password, boolean requireStaffAccount) throws NotAuthorizedException {
        UserService userService;
        try {
            userService = ServiceFactory.getUserService();
            User user = userService.getUser(email);
            if (user == null) {
                throw new NotAuthorizedException();
            }
            if (!userService.isUserAccountValid(user, password)) {
                throw new NotAuthorizedException();
            }
            if (requireStaffAccount) {
                if (!user.getIsStaff()) {
                    throw new NotAuthorizedException();
                }
            }
            return user;
        } catch (DatabaseAccessFailedException e) {
            e.printStackTrace();
            throw new NotAuthorizedException();
        }
    }
protected static User doAuthentication ( String email , String password , boolean requireStaffAccount ) throws NotAuthorizedException { UserService userService ; try { userService = ServiceFactory . getUserService ( ) ; User user = userService . getUser ( email ) ; if ( user == null ) { throw new NotAuthorizedException ( ) ; } if ( ! userService . isUserAccountValid ( user , password ) ) { throw new NotAuthorizedException ( ) ; } if ( requireStaffAccount ) { if ( ! user . getIsStaff ( ) ) { throw new NotAuthorizedException ( ) ; } } return user ; } catch ( DatabaseAccessFailedException e ) { e . printStackTrace ( ) ; throw new NotAuthorizedException ( ) ; } }
Apply authentication process to given email and password
 If required, the user will also be required to be a staff user
Apply authentication process to given email and password If required the user will also be required to be a staff user