Пример #1
0
        protected async override Task <int> ExecuteCommand(LoginCommand arguments)
        {
            Console.WriteLine("Logging out...");
            logger.LogInformation("Logging out... with {Arguments}", arguments);

            var userToken = await tokenStorage.LoadUserTokenAsync(); //Fetch before deleting tokens

            logger.LogInformation("Loaded {UserToken}", userToken);

            Console.WriteLine($"Deleting tokens...");
            await tokenStorage.DeleteAsync();

            Console.WriteLine($"Deleted tokens.");

            Console.WriteLine($"Deleting public keys...");
            await licensePublicKeyStorage.DestroyAsync();

            Console.WriteLine($"Deleted public keys.");

            Console.WriteLine($"Deleting stored licenses...");
            await licenseStorage.DeleteAsync();

            Console.WriteLine($"Deleted stored licenses.");

            if (userToken is null)
            {
                Console.WriteLine("User was not logged in. Can not revoke tokens...");
                Console.WriteLine("Logout was successful.");
                return(0);
            }

            var disco = await discoveryProvider.FetchDiscoveryDocument();

            var revokeRefreshTokenResult = await RevokeRefreshToken(userToken, disco);

            if (revokeRefreshTokenResult > 0)
            {
                return(revokeRefreshTokenResult);
            }
            var revokeAccessTokenResult = await RevokeAccessToken(userToken, disco);

            if (revokeAccessTokenResult > 0)
            {
                return(revokeAccessTokenResult);
            }

            Console.WriteLine("Logout was successful.");

            return(0);
        }