예제 #1
0
        /// <summary>
        ///   Login with the supplied credential.
        /// </summary>
        /// <param name="credential"> <para>The supplied credential.</para> </param>
        public void Login(ILoginCredential credential)
        {
            // Logout before logging in with new set of credentials
            if (IsLoggedIn)
            {
                Logout();
            }

            _authenticationContext = Authenticator.Instance.Login(credential, ConnectionOptions.ToLoginOptions());
            OnPrincipalChanged();
            OnLoggedIn();
        }
예제 #2
0
        /// <summary>
        ///   Login with the supplied credential.
        /// </summary>
        /// <param name="credential"> The supplied credential. </param>
        /// <param name="cancellationToken"> A token that allows for the operation to be cancelled. </param>
        public virtual async Task LoginAsync(ILoginCredential credential, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // Logout before logging in with new set of credentials
            if (IsLoggedIn)
            {
                await LogoutAsync();
            }

            _authenticationContext = await Authenticator.Instance.LoginAsync(
                credential, ConnectionOptions.ToLoginOptions(), cancellationToken);

            OnPrincipalChanged();
            OnLoggedIn();
        }