private void ClickValidate(object sender, RoutedEventArgs e)
        {
            string token = TextBoxToken.Text;

            if (!string.IsNullOrEmpty(token))
            {
                try
                {
                    Proxy.LoginServiceClient server = new Proxy.LoginServiceClient();
                    bool isVerified = server.VerificateUser(user, token);
                    server.Close();
                    if (isVerified)
                    {
                        CustomMessageBox.Show(Properties.Resources.SuccessfulVerification);
                        mainWindow.GoBack();
                    }
                    else
                    {
                        LabelAlert.Content = Properties.Resources.UnsuccessfulVerification;
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException ex)
                {
                    Console.WriteLine(ex.ToString());
                    LabelAlert.Content = Properties.Resources.ServerIsOff;
                }
            }
            else
            {
                LabelAlert.Content = Properties.Resources.EmptyFields;
            }
        }
        private void ClickRegister(object sender, RoutedEventArgs e)
        {
            string username             = TextBoxUsername.Text;
            string email                = TextBoxEmail.Text;
            string password             = TextBoxPassword.Password;
            string passwordConfirmation = TextBoxPasswordConfirmation.Password;

            if (!password.Equals(passwordConfirmation))
            {
                LabelAlert.Content = Properties.Resources.PasswordsDoNotMatch;
                return;
            }

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                String sFormato = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
                if (Regex.IsMatch(email, sFormato))
                {
                    try
                    {
                        Proxy.LoginServiceClient server = new Proxy.LoginServiceClient();
                        bool isValid = server.SignUp(username, email, password);
                        server.Close();
                        if (isValid)
                        {
                            user = username;
                            ShowValidateSection();
                        }
                        else
                        {
                            LabelAlert.Content = Properties.Resources.ExistingMail;
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ex)
                    {
                        Console.WriteLine(ex.ToString());
                        LabelAlert.Content = Properties.Resources.ServerIsOff;
                    }
                }
                else
                {
                    LabelAlert.Content = Properties.Resources.InvalidEmail;
                }
            }
            else
            {
                LabelAlert.Content = Properties.Resources.EmptyFields;
            }
        }
Exemple #3
0
        private void ClickValidate(object sender, EventArgs e)
        {
            string token = TextBoxToken.Text;

            if (!string.IsNullOrEmpty(token))
            {
                try
                {
                    Proxy.LoginServiceClient verificator = new Proxy.LoginServiceClient();
                    bool isVerified = verificator.VerificateUser(username, token);
                    verificator.Close();

                    if (isVerified)
                    {
                        ButtonChat.IsEnabled           = true;
                        TextBoxChat.IsEnabled          = true;
                        ButtonSeeScores.IsEnabled      = true;
                        ButtonChangePassword.IsEnabled = true;
                        ButtonPlay.IsEnabled           = true;

                        TextBoxToken.Visibility   = Visibility.Collapsed;
                        IconToken.Visibility      = Visibility.Collapsed;
                        ButtonValidate.Visibility = Visibility.Collapsed;
                        LabelAlert.Content        = Properties.Resources.AccountHasBeenVerifiedText;

                        server.JoinChat(0, username);
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.UnsuccessfulVerification);
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException ex)
                {
                    Console.WriteLine(ex.ToString());
                    LabelAlert.Content = Properties.Resources.ServerIsOff;
                }
            }
            else
            {
                MessageBox.Show(Properties.Resources.EmptyFields);
            }
        }
        private void ClickLogIn(object sender, RoutedEventArgs e)
        {
            string email    = TextBoxEmail.Text;
            string password = TextBoxPassword.Password;

            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                String emailFormat = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
                if (Regex.IsMatch(email, emailFormat))
                {
                    try
                    {
                        Proxy.LoginServiceClient server = new Proxy.LoginServiceClient();
                        string isValid = server.LogIn(email, password);
                        server.Close();
                        if (!string.IsNullOrEmpty(isValid))
                        {
                            MenuWindow sesion = new MenuWindow(isValid);
                            sesion.Show();
                            this.Close();
                        }
                        else
                        {
                            LabelAlert.Content = Properties.Resources.NoMatch;
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ex)
                    {
                        Console.WriteLine(ex.ToString());
                        LabelAlert.Content = Properties.Resources.ServerIsOff;
                    }
                }
                else
                {
                    LabelAlert.Content = Properties.Resources.InvalidEmail;
                }
            }
            else
            {
                LabelAlert.Content = Properties.Resources.EmptyFields;
            }
        }
Exemple #5
0
        /// <summary>
        /// The class constructor initializes the menu and verifies that the user is registered.
        /// </summary>
        /// <param name="username"> The user in logged in session. </param>
        public MenuWindow(string username)
        {
            InitializeComponent();
            content       = Content;
            this.username = username;

            context = new InstanceContext(this);
            server  = new Proxy.ChatServiceClient(context);
            Proxy.LoginServiceClient verificator = new Proxy.LoginServiceClient();

            if (verificator.IsVerified(username))
            {
                server.JoinChat(0, username);
            }
            else
            {
                UserNotVerified();
            }

            verificator.Close();
        }
        private void ClickRecover(object sender, RoutedEventArgs e)
        {
            string email = TextBoxEmail.Text;

            if (!string.IsNullOrEmpty(email))
            {
                String emailFormat = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
                if (Regex.IsMatch(email, emailFormat))
                {
                    try
                    {
                        Proxy.LoginServiceClient server = new Proxy.LoginServiceClient();
                        bool isValid = server.RecoverPassword(email);
                        server.Close();
                        if (isValid)
                        {
                            MessageBox.Show(Properties.Resources.EmailSent + email);
                            mainWindow.GoBack();
                        }
                        else
                        {
                            LabelAlert.Content = Properties.Resources.AccountNotFound;
                        }
                    }
                    catch (System.ServiceModel.EndpointNotFoundException ex)
                    {
                        Console.WriteLine(ex.ToString());
                        LabelAlert.Content = Properties.Resources.ServerIsOff;
                    }
                }
                else
                {
                    LabelAlert.Content = Properties.Resources.InvalidEmail;
                }
            }
            else
            {
                LabelAlert.Content = Properties.Resources.EmptyFields;
            }
        }