public static Response authenticateUser(Request request) {
		StrongPasswordEncryptor pEncrypt = new StrongPasswordEncryptor();

		String username = request.getSession().getUsername();
		String password = request.getSession().getPassword();

		User user = UserWrapper.getUserRowWithEmail(username);

		if (user != null
				&& pEncrypt.checkPassword(password, user.getPassword())) {
			Role role = Role.STUDENT;
			switch (user.getUserType()) {
			case "Teacher":
				role = Role.TEACHER;
				break;
			case "Admin":
				role = Role.ADMIN;
				break;
			}

			// Special case: If the Action was simply to "authenticate", the
			// client has
			// succeeded. There is no need to further route the Request.
			if (request.getAction().getAttribute().equals("authenticate")) {
				return new Response(ResponseStatus.SUCCESS, new RoleResource(
						role));
				// Otherwise, pass the Request to the Router to find out what to
				// do with it.
			}
			Request toRouter = new Request(request.getAction(),
					request.getResource(), role);
			return Router.getResponse(toRouter);
		}
		return new Response(ResponseStatus.FAILURE);
	}