Perhaps it would improve readibility of the code if you moved this convoluted if confition to a method like checkAuthenticated which returned a boolean.