#1135 Refactor of get_authenticated_users