Update the logout method to check the return url used and make sure it's safe
Remove the if __name__ == '__main__' since this is no longer working
Fix potential infinite loop in the logout method
Fix redirection in the @admin_required decorator