private async void registrar(object sender, RoutedEventArgs e)
        {

            var user = new ParseUser()
            {
                Username = usern.Text,
                Password = passw.Text,
            };

            user.Add("Name", name.Text);
            user.Add("Lastname", lastname.Text);
            user.Add("Ident", ident.Text);
            await user.SignUpAsync();

            Frame rootFrame = Window.Current.Content as Frame;
            rootFrame.Navigate(typeof(LoginPage));
        }
예제 #2
0
    public void TestImmutableKeys() {
      ParseUser user = new ParseUser();
      string[] immutableKeys = new string[] {
        "sessionToken", "isNew"
      };

      foreach (var key in immutableKeys) {
        Assert.Throws<InvalidOperationException>(() =>
          user[key] = "1234567890"
        );

        Assert.Throws<InvalidOperationException>(() =>
          user.Add(key, "1234567890")
        );

        Assert.Throws<InvalidOperationException>(() =>
          user.AddRangeUniqueToList(key, new string[] { "1234567890" })
        );

        Assert.Throws<InvalidOperationException>(() =>
          user.Remove(key)
        );

        Assert.Throws<InvalidOperationException>(() =>
          user.RemoveAllFromList(key, new string[] { "1234567890" })
        );
      }

      // Other special keys should be good
      user["username"] = "******";
      user["password"] = "******";
    }
        public async System.Threading.Tasks.Task<bool> Signup(Models.User newUser)
        {
            try
            {
                var user = new ParseUser()
                {
                    Email = newUser.Email,
                    Username = newUser.Email,
                    Password = newUser.Password
                };
                user.Add("Name", newUser.Name);
                await user.SignUpAsync();
            }
            catch (ParseException pex)
            {
                UIAlertView alert;
                if (pex.Code == ParseException.ErrorCode.UsernameTaken)
                {
                    alert = new UIAlertView("Cheers", "This username is already taken", null, "Ok", null);
                    alert.Show();
                }
                else if (pex.Code == ParseException.ErrorCode.EmailTaken)
                {
                    alert = new UIAlertView("Cheers", "This email is already taken", null, "Ok", null);
                    alert.Show();
                }
                else
                {
                    alert = new UIAlertView("Cheers", pex.Message, null, "Ok", null);
                    alert.Show();
                }
            }
            catch (InvalidOperationException inv)
            {
                UIAlertView alert = new UIAlertView("Cheers", inv.Message, null, "Ok", null);
                alert.Show();
            }
            catch (Exception ex)
            {
                UIAlertView alert = new UIAlertView("Cheers", ex.Message, null, "Ok", null);
                alert.Show();
            }

            return IsLoggedIn();
        }
예제 #4
0
        private async void register(object sender, RoutedEventArgs e)
        {
            string name_c = name.Text;
            string mail = email.Text;
            string fecha = Fecha_Nacimiento.Date.Day + "/" + Fecha_Nacimiento.Date.Month + "/" + Fecha_Nacimiento.Date.Year;
           
            int s = sex.SelectedIndex;
            string sexo="";
            switch (s)
            {
                case 0:
                    sexo = "Hombre";
                    break;
                case 1:
                    sexo = "Mujer";
                    break;
            }
            string userr = user.Text;
            string passs = pass.Password;
            string re_passs = re_pass.Password;
            int cont_error = 0;

            if (name_c.Equals("") || userr.Equals("") || passs.Equals("") || re_passs.Equals("") || mail.Equals(""))
            {
                Errors.Text = "Por favor llene todos los campos.";
                Errors.Visibility = Visibility.Visible;
                var margin = panel.Margin;
                margin.Top = -17;
                panel.Margin = margin;
                cont_error = 1;
            }
            if (!passs.Equals(re_passs))
            {
                Errors.Text = "Las contraseñas deben conicidir.";
                Errors.Visibility = Visibility.Visible;
                var margin = panel.Margin;
                margin.Top = -17;
                panel.Margin = margin;
                cont_error = 1;
            }
            if (cont_error == 0)
            {
                try
                {
                    PrgRing.Visibility = Visibility.Visible;
                    panel.Visibility = Visibility.Collapsed;
                    if (photo == null)
                    {
                        var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
                        var assetsFolder = await packageLocation.GetFolderAsync("Assets");
                        if (sexo.Equals("Mujer")){
                            photo = await assetsFolder.GetFileAsync("mujer.jpg");
                        }
                        else {
                            photo = await assetsFolder.GetFileAsync("hombre.jpg");
                        }

                    }
                    
                    
                    var bytes = await GetBtyeFromFile(photo);
                    ParseFile parseFile = new ParseFile(userr + ".jpg", bytes, "image/jpeg");
                    ParseUser user = new ParseUser()
                    {
                        Username = userr,
                        Password = passs,
                        Email = mail
                    };

                    // other fields can be set just like with ParseObject
                    user["name"] = name_c;
                    user["sex"] = sexo;
                    user["b_date"] = fecha;
                    user.Add("photo", null);

                    await user.SignUpAsync();
                    
                    PrgRing.Visibility = Visibility.Collapsed;
                    user["photo"] = parseFile;
                    await user.SaveAsync();
                    await ParseUser.LogInAsync(userr, passs);
                    
                    
                    Accept.Visibility = Visibility.Visible;
                    await Task.Delay(2000);
                    Frame rootFrame = Window.Current.Content as Frame;
                    rootFrame.Navigate(typeof(MainPage));
                }
                catch (Exception ex)
                {
                    PrgRing.Visibility = Visibility.Collapsed;
                    panel.Visibility = Visibility.Visible;
                    string error = ex.Message;
                    if (error.Contains("username"))
                    {
                        Errors.Text = "El usuario "+userr+" ya se encuentra registrado.";
                        Errors.Visibility = Visibility.Visible;
                        var margin = panel.Margin;
                        margin.Top = -17;
                        panel.Margin = margin;
                        cont_error = 1;
                    }
                    if (error.Contains("email"))
                    {
                        Errors.Text = "El correo electrónico " + mail + " ya se encuentra registrado.";
                        Errors.Visibility = Visibility.Visible;
                        var margin = panel.Margin;
                        margin.Top = -17;
                        panel.Margin = margin;
                        cont_error = 1;
                    }

                }
                
            }
        }
        public async System.Threading.Tasks.Task<bool> Signup(Models.User newUser)
        {
            try
            {
                var user = new ParseUser()
                {
                    Email = newUser.Email,
                    Username = newUser.Email,
                    Password = newUser.Password
                };
                user.Add("Name", newUser.Name);
                await user.SignUpAsync();
            }
            catch (ParseException pex)
            {
                Console.WriteLine(pex.Message);
            }
            catch (InvalidOperationException inv)
            {
                Console.WriteLine(inv.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return IsLoggedIn();
        }
예제 #6
0
    IEnumerator CadastrarUsuario()
    {
        _4Label.text = "Cadastrando Usuario...";
        _4btvoltar.gameObject.SetActive (false);
        if(ParseUser.CurrentUser != null)
            ParseUser.LogOut();
        bool cadastrando = true;
        string warningString =  "";
        ParseUser newUser = new ParseUser (){Username = _2NickEscolhido, Password = _2NickEscolhido};
        newUser.Add ("nome", _2OldString);
        newUser.SignUpAsync ().ContinueWith(task=> {

            if(task.IsFaulted)
            {
                print ("t is faulted");
        //				warningString = "Falha ao Cadastrar.";
        //
        //				print(task.Exception.Message);
        //				foreach(var ex in task.Exception.InnerExceptions){
        //					print(ex.Message);
        //				}
                //print(pex.HelpLink);
            }
            else if(task.IsCanceled)
            {
                print("t is canceled");
            }
            else
            {
                warningString = "Usuario cadastrado\ncom sucesso!";
            }
            cadastrando = false;
        });
        while(cadastrando)
            yield return null;
        _4Label.text = warningString;
        nickInputLogin.value = _2NickEscolhido;
        _4btvoltar.gameObject.SetActive(true);
    }