Ejemplo n.º 1
0
        private void textboxUser_TextChanged(object sender, EventArgs e)
        {
            SetEnableReg();
            lblInUse.Visible = false;
            bool isValid  = false;
            bool showIcon = false;

            if (!string.IsNullOrWhiteSpace(textboxUser.Text))
            {
                showIcon = true;
                if (DataAPI.IsValidEmail(textboxUser.Text))
                {
                    //bool inU
                    isValid          = DataAPIAnon.IsUsernameOK(textboxUser.Text);
                    lblInUse.Visible = !isValid;
                }
            }
            textboxUser.Tag    = isValid;
            pbUsername.Visible = showIcon;
            if (isValid)
            {
                pbUsername.Image = imageOK;
            }
            else
            {
                pbUsername.Image = imageNO;
            }
        }
Ejemplo n.º 2
0
        private void textBoxSitename_TextChanged(object sender, EventArgs e)
        {
            bool isValid  = false;
            bool showIcon = false;

            if (textBoxSitename.Text.Length > 2)
            {
                showIcon = true;
                isValid  = DataAPIAnon.IsTeamnameOK(textBoxSitename.Text);
            }
            pbSitename.Visible = showIcon;
            if (isValid)
            {
                pbSitename.Image = imageOK;
            }
            else
            {
                pbSitename.Image = imageNO;
            }
        }
Ejemplo n.º 3
0
        private void textboxPassword_TextChanged(object sender, EventArgs e)
        {
            SetEnableReg();
            bool isValid  = false;
            bool showIcon = false;

            if (!string.IsNullOrWhiteSpace(textboxPassword.Text))
            {
                showIcon = true;
                isValid  = DataAPIAnon.IsGoodPassword(textboxPassword.Text);
            }
            textboxPassword.Tag = isValid;
            pbPassword.Visible  = showIcon;
            if (isValid)
            {
                pbPassword.Image = imageOK;
            }
            else
            {
                pbPassword.Image = imageNO;
            }
            lblPwdRules.Visible = !isValid;
        }
Ejemplo n.º 4
0
        private void bRegister_Click(object sender, EventArgs e)
        {
            string regResult = "";

            //Register
            if (string.IsNullOrWhiteSpace(textboxLastname.Text) || string.IsNullOrWhiteSpace(textboxUser.Text) || string.IsNullOrWhiteSpace(textboxPassword.Text) || !cbIAgree.Checked)
            {
                regResult = "Missing registration information.";
            }
            else
            {
                rModel = new RegisterModel()
                {
                    Firstname  = textBoxFirstname.Text,
                    Lastname   = textboxLastname.Text,
                    Sitename   = textBoxSitename.Text,
                    UserName   = textboxUser.Text,
                    Password   = textboxPassword.Text,
                    userAgreed = cbIAgree.Checked,
                    freeTrial  = cbFreeTrial.Checked
                };
                regResult = DataAPIAnon.Register(rModel);
            }
            if (regResult == "")
            {
                string token = DataAPIAnon.GetAuthToken(rModel.UserName, rModel.Password, 30, cbRemember.Checked);
                DataAPI.SetToken(token);
                loginForm.LoadInputs(rModel.UserName, rModel.Password);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                DialogResult res = MessageBox.Show(regResult, "Unable to Register", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                Globals.ThisAddIn.APIEnv = (ShuriEnvironment)ddEnviro.SelectedItem;
                string token = DataAPIAnon.GetAuthToken(this.textboxUser.Text, this.textboxPassword.Text, 30, checkboxSavePwd.Checked);
                this.Cursor = Cursors.Default;
                string msg = "";


                if (token.Length > 5)
                {
                    switch (token.Substring(0, 5))
                    {
                    case "Error":
                        msg = token.Substring(5).Trim();
                        if (MessageBox.Show(msg + "\n\nTry again?", "Login Failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
                        {
                            this.DialogResult = DialogResult.No;
                        }
                        break;

                    case "offli":
                        msg = "Unable to contact Shuri\r\n\r\nRetry or press Cancel to work offline.";
                        DialogResult res = MessageBox.Show(msg, "Login timed out", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
                        if (res == DialogResult.Cancel)
                        {
                            this.DialogResult = DialogResult.Cancel;
                            this.Close();
                        }
                        break;

                    default:
                        DataAPI.SetToken(token);
                        DataAPI.Login(true);
                        Globals.ThisAddIn.InitTheSync();

                        //reenable
                        Globals.ThisAddIn.Enabled = true;

                        //save message - 1 time
                        if (Utilities.ReadRegStringValue("saveMessageShown") == null)
                        {
                            MessageBox.Show(String.Format("Login successful.\r\n\r\nSince you chose to save your password,\r\nyou will be automatically logged in to Shuri\r\nevery time you start Outlook.\r\n\r\nThis message will not display again.", Properties.Resources.AddinName), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Utilities.SetRegistryValue(Properties.Resources.RegistryPath, "saveMessageShown", "true", Microsoft.Win32.RegistryValueKind.String);
                        }


                        this.DialogResult = DialogResult.Yes;
                        this.Close();

                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Login Failed: ", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.No;
            }
        }