factorize login/logout actions