コード例 #1
0
        /// <summary>
        /// Removes the saved settings for a user and returns them to the log in screen
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public async void LogOutUser(object sender, EventArgs e)
        {
            var userID = KeychainAccess.ValueForKey("userID");

            await ion.portal.LogoutAsync();

            ion.settings._portal.rememberMe = false;
            ion.settings._portal.userId     = 0;
            ion.settings._portal.username   = "";
            ion.settings._portal.password   = "";

            loginView = new RemoteLoginView(remoteHolderView);
            loginView.submitButton.TouchUpInside += credentialsCheck;
            remoteHolderView.AddSubview(loginView.loginView);
            portalControl.portalView.RemoveFromSuperview();
            portalControl.uploadButton.TouchUpInside -= showUploads;
            portalControl.codeButton.TouchUpInside   -= showCodeManager;
            portalControl.accessButton.TouchUpInside -= showAccessManager;
            portalControl.remoteButton.TouchUpInside -= showRemoteViewing;

            portalControl = null;

            profileView.profileView.RemoveFromSuperview();
            profileView = null;
            this.NavigationItem.RightBarButtonItem = register;
        }
コード例 #2
0
        private async Task <bool> CredentialsCheck(bool remember, string username, string password)
        {
            try {
                var response = await ion.portal.RequestLoginAsync(username, password);

                if (response.success)
                {
                    if (remember)
                    {
                        ion.settings.portal.rememberMe = true;
                        ion.settings.portal.username   = response.result.username;
                        ion.settings.portal.password   = response.result.password;
                    }

                    portalControl = new PortalMenu(remoteHolderView);
                    portalControl.uploadButton.TouchUpInside += showUploads;
                    portalControl.codeButton.TouchUpInside   += showCodeManager;
                    portalControl.accessButton.TouchUpInside += showAccessManager;
                    portalControl.remoteButton.TouchUpInside -= showRemoteViewing;
                    portalControl.remoteButton.TouchUpInside += showRemoteViewing;

                    remoteHolderView.AddSubview(portalControl.portalView);
                    profileView = new RemoteUserProfileView(remoteHolderView);
                    profileView.logoutButton.TouchUpInside += LogOutUser;

                    remoteHolderView.AddSubview(profileView.profileView);
                    this.NavigationItem.RightBarButtonItem = settingsButton;
                    return(true);
                }
                else
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var rootVC = window.RootViewController as IONPrimaryScreenController;
                    switch (response.error)
                    {
                    case IONPortalService.EError.InternalError: {
                        var alert = UIAlertController.Create("Log In", "There was no response. Please try again.", UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));
                        rootVC.PresentViewController(alert, animated: true, completionHandler: null);
                    } break;

                    default: {
                        var failMessage = "US Failed to login: US";
                        ion.settings.portal.rememberMe = false;
                        var alert = UIAlertController.Create("Log In", failMessage, UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));
                        rootVC.PresentViewController(alert, animated: true, completionHandler: null);
                    } break;
                    }
                    return(false);
                }
            } catch (Exception e) {
                Log.E(this, "Failed to validate credentials", e);
                return(false);
            }
        }