public static void createNewUser(string username, string password, System.Action<bool> complete)
 {
     ParseUser user = new ParseUser (){
         Username = username,
         Password = password,
         Email = username + "@fakeEmailabc123.com"
     };
     user.SignUpAsync().ContinueWith(t => {
         if (t.IsFaulted) {
             // Errors from Parse Cloud and network interactions
             using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator()) {
                 if (enumerator.MoveNext()) {
                     ParseException error = (ParseException) enumerator.Current;
                     // error.Message will contain an error message
                     // error.Code will return "OtherCause"
                     Debug.Log(error.Code + " : " + error.Message);
                     complete(false);
                 }
             }
         }
         else {
             complete(true);
         }
     });
 }
		//Sample Parse Function 
		public async Task RegUser (string un, string ps, string em)
		{

			ParseUser user = new ParseUser ();
			user.Username = un;
			user.Password = ps;
			user.Email = em;

			// other fields can be set just like with ParseObject
			//user ["phone"] = "415-392-0202";

			try
			{
				await user.SignUpAsync ();
				Console.WriteLine ("Account Creation Success");
				// Login was successful.
				//TODO: Open up a new page
				//await Navigation.PushModalAsync (new NEWPAGENAME () );
			}
			catch (Exception e)
			{
				// The login failed. Check the error to see why.
				Console.WriteLine("Signup error: " + e.Message);
				DisplayAlert ("Error", e.Message, "OK", "Cancel");
			}


		}
        public async Task<User> CreateUser(string username, string pass, string email)
        {
            try
            {
                var user = new ParseUser()
                {
                    Username = username,
                    Password = pass,
                    Email = email
                };

                User createdUser = new User()
                {
                    Username = user.Username
                };

                await user.SignUpAsync();

                await ParseUser.LogInAsync(username, pass);
                ((App)App.Current).AuthenticatedUser = ParseUser.CurrentUser;

                return createdUser;
            }
            catch (Exception e)
            {
                new MessageDialog(e.Message).ShowAsync();
                return null;
            }
        }
    public Task TestExistsAsync() {
      var controller = new ParseCurrentUserController();
      var user = new ParseUser();

      return controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
        Assert.AreEqual(user, controller.CurrentUser);
        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsTrue(t.Result);

        controller.ClearFromMemory();

        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsTrue(t.Result);

        controller.ClearFromDisk();

        return controller.ExistsAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.IsFalse(t.Result);
      });
    }
    public Task TestGetSetAsync() {
      var storageController = new Mock<IStorageController>(MockBehavior.Strict);
      var mockedStorage = new Mock<IStorageDictionary<string, object>>();
      var controller = new ParseCurrentUserController(storageController.Object);
      var user = new ParseUser();

      storageController.Setup(s => s.LoadAsync()).Returns(Task.FromResult(mockedStorage.Object));

      return controller.SetAsync(user, CancellationToken.None).OnSuccess(_ => {
        Assert.AreEqual(user, controller.CurrentUser);

        object jsonObject = null;
        Predicate<object> predicate = o => {
          jsonObject = o;
          return true;
        };

        mockedStorage.Verify(s => s.AddAsync("CurrentUser", Match.Create<object>(predicate)));
        mockedStorage.Setup(s => s.TryGetValue("CurrentUser", out jsonObject)).Returns(true);

        return controller.GetAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.AreEqual(user, controller.CurrentUser);

        controller.ClearFromMemory();
        Assert.AreNotEqual(user, controller.CurrentUser);

        return controller.GetAsync(CancellationToken.None);
      }).Unwrap()
      .OnSuccess(t => {
        Assert.AreNotSame(user, controller.CurrentUser);
        Assert.IsNotNull(controller.CurrentUser);
      });
    }
	public virtual void AddUser(ParseDatastoreMaster pdm ){

		pdm.Dismiss ();

		var user = new ParseUser()
		{
			Username = username.text,
			Password = password.text,
			Email = email.text
		};


		user.SignUpAsync().ContinueWith (t =>
		                                 {
			if (t.IsFaulted || t.IsCanceled)
			{
				// The login failed. Check the error to see why.
				print ("signup failed!");
				print (t.Exception.Message);
				pdm.updateLoginStateFlag = true;
			}
			else
			{
				// Login was successful.
				print ("signup success");
				pdm.updateLoginStateFlag = true;
			}
		});
		
		
	}
Beispiel #7
0
        public async Task<ActionResult> CreateUser(FormCollection form)
        {
            try
            {
                var user = new ParseUser()
                {
                    Username = form["username"],
                    Password = form["password"],
                    Email = form["email"]
                };

                user["firstName"] = form["firstName"].ToString();
                user["lastName"] = form["lastName"].ToString();
                user["phoneNumber"] = form["phoneNumber"].ToString();
                user["address"] = form["address"].ToString();
                user["birthday"] = DateTime.Parse(form["birthday"].ToString());
                user["gender"] = bool.Parse(form["gender"]);
                user["role"] = form["role"].ToString();

                await user.SaveAsync();
                return RedirectToAction("UserList");
            }
            catch (ParseException pe)
            {
                ViewBag.Error = "Error input form " + pe.Message + " ! Please retry";
                return View();
            }
        }
    void CreateUser()
    {
        ParseUser.LogOut();
        var user = new ParseUser(){
            Username = usuario,
            Password = pwd,
            Email = email
        };

        // other fields can be set just like with ParseObject
        user["pontuacao"] = (int) scoreInicial;

        user.SignUpAsync().ContinueWith( t => {
            if (t.IsFaulted || t.IsCanceled)
            {
                foreach (var e in t.Exception.InnerExceptions)
                {
                    ParseException parseException = (ParseException)e;
                    Debug.Log("Error message " + parseException.Message);
                    Debug.Log("Error code: " + parseException.Code);
                }
            }
            else
            {
                //SignUpAsync(); //DONE
                Debug.Log("Usuário criado com sucesso");
            }
        });

        ParseUser.LogOut();
    }
        public async Task<IHttpActionResult> SignUp([FromBody]Usuario user)
        {
            try
            {
                ParseUser usuario = new ParseUser()
                {
                    Username = user.usuario,
                    Password = user.psw,
                    Email = user.correo
                };
                usuario["nombre"] = user.nombre;
                Byte[] bytes = Convert.FromBase64String(user.foto);
                ParseFile foto = new ParseFile("foto.png", bytes);
                await foto.SaveAsync();
                usuario["foto"] = foto;
                usuario["sexo"] = user.sexo;
                usuario["tipo"] = user.tipo;
                await usuario.SignUpAsync();

                Usuario resp = new Usuario();
                resp.usuario = user.usuario;
                resp.psw = user.psw;
                resp.correo = usuario.Get<string>("email");
                resp.foto = usuario.Get<ParseFile>("foto").Url.AbsoluteUri;
                resp.sexo = usuario.Get<string>("sexo");
                resp.tipo = usuario.Get<string>("tipo");
                resp.nombre = usuario.Get<string>("nombre");
                resp.ObjectId = usuario.ObjectId;
                return Ok(resp);
            }
            catch (ParseException e) {
                return InternalServerError(e);
            }
            
        }
	void Registration()
	{
		Debug.LogError("Registration has been called");
		 if (usernameRegister.text == "Your full name" || emailRegister.text == "Your email" || repassRegister.text == "Enter password again" || usernameRegister.text == "" || emailRegister.text == "" || passwordRegister.text == "" || repassRegister.text == "")
		{
			message = "Please enter all the fields";
			Debug.LogError ("" +message);
		}
            else
            {
                if (passwordRegister.text == repassRegister.text)
                {
					Debug.LogError("Passwords Matched");
					var userCurrent = new ParseUser(){
						Username = usernameRegister.text,
						Email = emailRegister.text,
						Password = passwordRegister.text
					};
//					Debug.LogError ("" +userCurrent);
					Task signUpTask = userCurrent.SignUpAsync();
					message = "Sign up successful. Check your email for verification!";
                }
                else
		{
                   message = "Your Password does not match";
            }
	}
	}
Beispiel #11
0
    private void SignUp(string username, string password, string email, Dictionary<string, string> signUpParams)
    {
        var user = new ParseUser()
        {
            Username = username,
            Password = password,
            Email = email
        };

        foreach(var kvp in signUpParams) {
            user[kvp.Key] = kvp.Value;
        }
        user.SignUpAsync();
        /*	Task signUpTask = user.SignUpAsync();
        signUpTask.ContinueWith(
        task => {
            Debug.Log("Calling cloud function");
            ParseCloud.CallFunctionAsync<Dictionary<string,object>>("GetSuggestions", new Dictionary<string, object>()).ContinueWith(
            t => {
                var suggestions = t.Result;
                if(suggestions != null) {
                    foreach(var kvp in suggestions) {
                        Debug.Log(kvp.Key + " " + kvp.Value);
                    }
                }
            });
        });*/
    }
Beispiel #12
0
 private static async Task Login(string username, string password)
 {
     await Task.Delay(1000);
     await ParseUser.LogInAsync(username, password);
     await Task.Delay(1000);
     currentUser = ParseUser.CurrentUser;
 }
		public async void signup(string email, string password, Action signupSuccess, Action signupError) {
			var user = new ParseUser ()
			{
				Username = email,
				Email = email,
				Password = password
			};
			try 
			{
				await user.SignUpAsync();
				Console.WriteLine("signup done");
				if (ParseUser.CurrentUser != null)
				{
					Console.WriteLine("Connected as : {0}", ParseUser.CurrentUser.Get<string>("username"));
					signupSuccess();
				}
				else
				{
					throw new Exception ("Parse Current User null");
				}
			} 
			catch (Exception e)
			{
				Console.WriteLine("Signup did not work : "+e.Message);
				signupError();
			}
		}
Beispiel #14
0
 public static User Map(ParseUser puser)
 {
     User user = new User();
     user.UserName = puser.Username;
     user.ObjectId = puser.ObjectId;
     user.Email = puser.Email;
     return user;
 }
Beispiel #15
0
 private void SignUp()
 {
     ParseUser userToSignUp = new ParseUser() {
         Username = CurrentUser.Username,
         Password = CurrentUser.Password
     };
     userToSignUp.SignUpAsync();
 }
 public PrincipalPage()
 {
     this.InitializeComponent();
     rootFrame = Window.Current.Content as Frame;
     parseFun = new FundacionParse();
     parseEventos = new EventoParse();
     usuario = new ParseUser();
 }
Beispiel #17
0
        public void getCurrentUsername()
        {
            currentUser = ParseUser.CurrentUser;
            if (currentUser == null)
                return;

            vm.setCurrentUserName(currentUser.Username);
        }
    public void ParseSignUp()
    {
        if (ParseUser.CurrentUser != null)
        {
            Debug.Log("Parse has been logined!");
        }
        else
        {
            if (username.text != "" && username.text != "Username" && password.text != "")
            {
                ParseUser user;

                if (email.text != "" && email.text != "email")
                {
                    user = new ParseUser()
                    {
                        Username = username.text,
                        Password = password.text,
                        Email = email.text
                    };
                }
                else
                {
                    user = new ParseUser()
                    {
                        Username = username.text,
                        Password = password.text
                    };
                }

                Task signUpTask = user.SignUpAsync().ContinueWith(t =>
                {
                    if (t.IsCompleted)
                    {
                        Debug.Log("Sign Up success!");
                    }
                    else
                    {
                        Debug.Log("Sign up failed!");

                        // Errors from Parse Cloud and network interactions
                        using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator())
                        {
                            if (enumerator.MoveNext())
                            {
                                ParseException error = (ParseException)enumerator.Current;
                                // error.Message will contain an error message
                                // error.Code will return "OtherCause"
                            }
                        }
                    }
                });
               
                StartCoroutine(_ShowLoginScreen(signUpTask));
            }
        }

    }
Beispiel #19
0
		/// <summary>
		/// Buttons the create account touch up inside.
		/// </summary>
		/// <param name="sender">Sender.</param>
		async partial void btnCreateAccount_TouchUpInside (UIButton sender)
		{
			var firstName = txtFirstName.Text;
			var lastName = txtLastName.Text;
			var username = txtUser.Text;
			var password = txtPassword.Text;
			var confirmPassword = txtConfirm.Text;

			var alert = new UIAlertView();

			if ((string.IsNullOrEmpty(username)) || (string.IsNullOrEmpty(password)) ||
				(string.IsNullOrEmpty(firstName)) ||
				(string.IsNullOrEmpty(lastName)))

			{
				alert = new UIAlertView("Input Validation Failed", "Please complete all the input fields!", null, "OK");
				alert.Show();
			}
			else
			{
				if (password != confirmPassword)
				{
					alert = new UIAlertView("Input Validation Failed", "Password and Confirm Password must match!", null, "OK");
					alert.Show();
				}
				else
				{
					try
					{
						var user = new ParseUser()
						{
							Username = username,
							Password = password,
						
						} ;

						user["LastName"] = lastName;
						user["FirstName"] = firstName;

						await user.SignUpAsync();

						alert = new UIAlertView("Account Created", "Your account has been successfully created!", null, "OK");
						alert.Show();

						NavigationController.PopViewController (true);

					}
					catch(Exception ex)
					{
						var error = ex.Message;
						alert = new UIAlertView("Registration Failed", "Sorry, we might be experiencing some connectivity difficulties or your email is already in the system!", null, "OK");
						alert.Show();
					}
				}
			}
		}		
        internal static UserViewModel FromModel(ParseUser parseUser)
        {
            var userCategories = parseUser["categories"] as IEnumerable<object>;

            return new UserViewModel()
            {
                Username = parseUser.Username,
                Categories = (parseUser["categories"] as IEnumerable<object>).Select(cat=> cat as CategoryModel)
            };
        }
Beispiel #21
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (!localSettings.Values.ContainsKey("username"))
            {
                try
                {
                    userfb = await ParseFacebookUtils.LogInAsync(browser, new[] { "user_about_me", "email" });
                    browser.Visibility = Visibility.Collapsed;
                    var usersPosts = await ParseObject.GetQuery("GhiChu").WhereEqualTo("user", userfb).FindAsync();
                    if (usersPosts.Count() > 0)
                    {
                        ccc.Text = "Tài khoản facebook của bạn có " + usersPosts.Count().ToString() + " ghi chú.";
                    }
                    else
                    {
                        ccc.Text = "Tài khoản facebook của bạn chưa có dữ liệu.";
                        btnDown.Visibility = Visibility.Collapsed;
                    }
                    var fb = new FacebookClient();
                    fb.AccessToken = ParseFacebookUtils.AccessToken;
                    dynamic me = await fb.GetTaskAsync("me");
                    ProfilePic.Source = new BitmapImage(new Uri("https://graph.facebook.com/" + me["id"] + "/picture"));
                    FBName.Text = me["name"];
                    localSettings.Values["name"] = me["name"];
                    localSettings.Values["username"] = userfb.Username;
                    localSettings.Values["image"] = "https://graph.facebook.com/" + me["id"] + "/picture";
                    Content.Visibility = Visibility.Visible;
                    ProgressRingGrid.Visibility = Visibility.Collapsed;
                }
                catch
                {

                }
            }
            else
            {
                var user = await ParseUser.Query.WhereEqualTo("username", localSettings.Values["username"].ToString()).FindAsync();
                userfb = user.First();
                var usersPosts = await ParseObject.GetQuery("GhiChu").WhereEqualTo("user", userfb).FindAsync();
                if (usersPosts.Count() > 0)
                {
                    ccc.Text = "Tài khoản facebook của bạn có " + usersPosts.Count().ToString() + " ghi chú.";
                }
                else
                {
                    ccc.Text = "Tài khoản facebook của bạn chưa có dữ liệu.";
                    btnDown.Visibility = Visibility.Collapsed;
                }
                FBName.Text = localSettings.Values["name"].ToString();
                ProfilePic.Source = new BitmapImage(new Uri(localSettings.Values["image"].ToString()));
                Content.Visibility = Visibility.Visible;
                ProgressRingGrid.Visibility = Visibility.Collapsed;
            }
        }
 public void addMessage(string message,ParseUser receiver)
 {
     if(receiver==null)
         return;
     ParseObject parseMessage = new ParseObject("Message");
     parseMessage["message_text"] = message;
     parseMessage["receiver"] = receiver;
     parseMessage["sender"] = ParseUser.CurrentUser;
     parseMessage["timestamp"] = DateTime.Now.Ticks;
     StartCoroutine(saveMessage(parseMessage));
 }
 private async void goToRegistrarusuario(object sender, RoutedEventArgs e)
 {
     var user = new ParseUser()
     {
         Username = nombre.Text,
         Password = password.Text,
         Email = correo.Text
     };
     user["profesion"] = profesion.Text;
     await user.SignUpAsync();
 }
Beispiel #24
0
        public override void OnEnter()
        {
            ParseUser user = new ParseUser()
            {
                Username = username.IsNone ? email.Value : username.Value,
                Password = password.Value,
                Email = email.Value
            };

            _task = user.SignUpAsync();
        }
	void CreateNewUser(string userName, string password, string email)
	{
		var user = new ParseUser()
		{
		    Username = userName,
		    Password = password,
		    Email = email
		};
		
		user.SignUpAsync();
		Application.LoadLevel("Demo");
	}
 private async void Inscription_Click(object sender, RoutedEventArgs e)
 {
     var user = new ParseUser()
     {
         Username = UserName.Text,
         Password = MDP.Password,
         Email = EmailName.Text
     };
     await user.SignUpAsync();
     user["type"] = "student";
     Frame.GoBack();
 }
 // LOGIN / SIGNUP
 public async void LoginOrCreateAccount() {
     try {
         await ParseUser.LogInAsync("test", "test");
     }
     catch {
         ParseUser newUser = new ParseUser() {
             Username = "******",
             Password = "******"
         };
         await newUser.SignUpAsync();
     }
     await GetUserTasks();
 }
 /// <summary>
 /// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
 /// for authentication, and providing access to Facebook data for the user.
 /// 
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="user">The user to link with Facebook.</param>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static async Task LinkAsync(ParseUser user,
     WebBrowser webView,
     IEnumerable<string> permissions,
     CancellationToken cancellationToken) {
   authProvider.Permissions = permissions;
   LoadCompletedEventHandler loadCompleted = (_, e) => authProvider.HandleNavigation(e.Uri);
   webView.LoadCompleted += loadCompleted;
   Action<Uri> navigate = uri => webView.Navigate(uri);
   authProvider.Navigate += navigate;
   await user.LinkWithAsync("facebook", cancellationToken);
   authProvider.Navigate -= navigate;
   webView.LoadCompleted -= loadCompleted;
 }
Beispiel #29
0
    void CreateUser()
    {
        var user = new ParseUser()
        {
            Username = "******",
            Password = "******",
            Email = "*****@*****.**"
        };

        // other fields can be set just like with ParseObject
        user["phone"] = "650-555-0000";

        user.SignUpAsync();
    }
		async void btnOneTapSignUp_Clicked(object sender, EventArgs args)
		{
			var query = from dictionary in ParseObject.GetQuery("Dictionary")
					where dictionary.Get<int>("dicType") == 1 && dictionary.Get<bool>("isAvailable")
				select dictionary;
			IEnumerable<ParseObject> results = await query.Limit(1).FindAsync();

			if (results == null || results.Count() <= 0) 
			{
				await DisplayAlert ("Sign Up Failed", "There's no available usernames in the pool.", "OK");
				return;
			}

			var dic = results.First();
//			// or using LINQ
//			var query = ParseObject.GetQuery("GameScore").WhereEqualTo("playerName", "Dan Stemkoski");
//			IEnumerable<ParseObject> results = await query.FindAsync();

			if (dic == null) 
			{
				await DisplayAlert ("Sign Up Failed", "There's no available usernames in the pool.", "OK");
				return;
			}
				
			string userName = dic.Get<string> ("dicValue");
			string password = "******";
			var user = new ParseUser()
			{
				Username = userName,
				Password = password
			};
			await user.SignUpAsync ();

			dic["isAvailable"] = false;
			await dic.SaveAsync ();

			await ParseUser.LogInAsync (userName, password);

			App.Database.DeleteAllLocalInfos ();

			LocalInfo localInfo = new LocalInfo ();
			localInfo.UserName = userName;
			localInfo.Passcode = password;
			localInfo.Active = true;
			App.Database.SaveLocalInfo (localInfo);

			lblTitle.Text = "Welcome " + userName;
			lblMessage.Text = "New user signed up: \n" + userName + "  --  " + password;
		}
Beispiel #31
0
 /// <summary>
 /// Unlinks a user from a Facebook account. Unlinking a user will save the user's data.
 /// </summary>
 /// <param name="user">The user to unlink.</param>
 public static Task UnlinkAsync(ParseUser user)
 {
     return(UnlinkAsync(user, CancellationToken.None));
 }
Beispiel #32
0
 /// <summary>
 /// Initializes Facebook for use with Parse.
 /// </summary>
 /// <param name="applicationId">Your Facebook application ID.</param>
 public static void Initialize(string applicationId)
 {
     authProvider.AppId = applicationId;
     ParseUser.RegisterProvider(authProvider);
 }
Beispiel #33
0
 /// <summary>
 /// Creates an ACL where only the provided user has access.
 /// </summary>
 /// <param name="owner">The only user that can read or write objects governed by this ACL.</param>
 public ParseACL(ParseUser owner)
 {
     SetReadAccess(owner, true);
     SetWriteAccess(owner, true);
 }
Beispiel #34
0
 /// <summary>
 /// Links a <see cref="ParseUser" /> to a Facebook account, allowing you to use Facebook
 /// for authentication, and providing access to Facebook data for the user.
 ///
 /// The user will be logged in through Facebook's OAuth web flow, so you must supply a
 /// <paramref name="webView"/> that will be navigated to Facebook's authentication pages.
 /// </summary>
 /// <param name="user">The user to link with Facebook.</param>
 /// <param name="webView">A web view that will be used to present the authorization pages
 /// to the user.</param>
 /// <param name="permissions">A list of Facebook permissions to request.</param>
 public static Task LinkAsync(ParseUser user, WebBrowser webView, IEnumerable <string> permissions)
 {
     return(LinkAsync(user, webView, permissions, CancellationToken.None));
 }
Beispiel #35
0
 private static Task SaveCurrentUserAsync(ParseUser user)
 {
     return(SaveCurrentUserAsync(user, CancellationToken.None));
 }
Beispiel #36
0
 /// <summary>
 /// Unity will just auto-initialize this. Since we're not responsible for login, we don't
 /// need the application id -- just the tokens.
 /// </summary>
 internal static void Initialize()
 {
     ParseUser.RegisterProvider(authProvider);
 }
Beispiel #37
0
 /// <summary>
 /// Saves the provided <see cref="ParseUser"/> instance with the target Parse Server instance and then authenticates it on the target client. This method should only be used once <see cref="ParseClient.Publicize"/> has been called and <see cref="ParseClient.Instance"/> is the wanted bind target, or if <see cref="ParseObject.Services"/> has already been set or <see cref="ParseObject.Bind(IServiceHub)"/> has already been called on the <paramref name="user"/>.
 /// </summary>
 /// <param name="serviceHub">The <see cref="IServiceHub"/> instance to target when creating the user and authenticating.</param>
 /// <param name="user">The <see cref="ParseUser"/> instance to save on the target Parse Server instance and authenticate.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static Task SignUpAsync(this IServiceHub serviceHub, ParseUser user, CancellationToken cancellationToken = default)
 {
     user.Bind(serviceHub);
     return(user.SignUpAsync(cancellationToken));
 }
Beispiel #38
0
 /// <summary>
 /// Unlinks a user from a Facebook account. Unlinking a user will save the user's data.
 /// </summary>
 /// <param name="user">The user to unlink.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static Task UnlinkAsync(ParseUser user, CancellationToken cancellationToken)
 {
     return(user.UnlinkFromAsync("facebook", cancellationToken));
 }
Beispiel #39
0
 /// <summary>
 /// Gets whether the given user is linked to a Facebook account. This can only be used on
 /// the currently authorized user.
 /// </summary>
 /// <param name="user">The user to check.</param>
 /// <returns><c>true</c> if the user is linked to a Facebook account.</returns>
 public static bool IsLinked(ParseUser user)
 {
     return(user.IsLinked("facebook"));
 }
Beispiel #40
0
 private static Task SaveCurrentUserAsync(ParseUser user, CancellationToken cancellationToken)
 {
     return(CurrentUserController.SetAsync(user, cancellationToken));
 }
Beispiel #41
0
 /// <summary>
 /// Sets whether the given user is allowed to write this object.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="allowed">Whether the user has permission.</param>
 public void SetWriteAccess(ParseUser user, bool allowed)
 {
     SetWriteAccess(user.ObjectId, allowed);
 }
Beispiel #42
0
 /// <summary>
 /// Gets whether the given user is *explicitly* allowed to write this object.
 /// Even if this returns false, the user may still be able to write it if
 /// PublicReadAccess is true or a role that the user belongs to has write access.
 /// </summary>
 /// <param name="user">The user to check.</param>
 /// <returns>Whether the user has access.</returns>
 public bool GetWriteAccess(ParseUser user)
 {
     return(GetWriteAccess(user.ObjectId));
 }
Beispiel #43
0
 /// <summary>
 /// Logs in a user with a username and password. On success, this saves the session to disk or to memory so you can retrieve the currently logged in user using <see cref="GetCurrentUser(IServiceHub)"/>.
 /// </summary>
 /// <param name="serviceHub">The <see cref="IServiceHub"/> instance to target when logging in.</param>
 /// <param name="username">The username to log in with.</param>
 /// <param name="password">The password to log in with.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The newly logged-in user.</returns>
 public static Task <ParseUser> LogInAsync(this IServiceHub serviceHub, string username, string password, CancellationToken cancellationToken = default) => serviceHub.UserController.LogInAsync(username, password, serviceHub, cancellationToken).OnSuccess(task =>
 {
     ParseUser user = serviceHub.GenerateObjectFromState <ParseUser>(task.Result, "_User");
     return(SaveCurrentUserAsync(serviceHub, user).OnSuccess(_ => user));
 }).Unwrap();
Beispiel #44
0
 /// <summary>
 /// Logs in a user with a username and password. On success, this saves the session to disk so you
 /// can retrieve the currently logged in user using <see cref="GetCurrentUser()"/>.
 /// </summary>
 /// <param name="sessionToken">The session token to authorize with</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The user if authorization was successful</returns>
 public static Task <ParseUser> BecomeAsync(this IServiceHub serviceHub, string sessionToken, CancellationToken cancellationToken = default) => serviceHub.UserController.GetUserAsync(sessionToken, serviceHub, cancellationToken).OnSuccess(t =>
 {
     ParseUser user = serviceHub.GenerateObjectFromState <ParseUser>(t.Result, "_User");
     return(SaveCurrentUserAsync(serviceHub, user).OnSuccess(_ => user));
 }).Unwrap();