thieumao

Simple Login Singup in Parse.com Unity

Aug 28th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using Parse;
  4. using System.Threading.Tasks;
  5.  
  6. public class User : MonoBehaviour {
  7.  
  8.     // Use this for initialization
  9.     void Start () {
  10.         //Signup("thieumao","1234567","[email protected]","0917735107");
  11.         //Signup("motmao", "123456", "[email protected]");
  12.        
  13.        
  14.         Login("thieumao","123456");
  15.     }
  16.  
  17.     private void Signup(string myName, string myPass, string myEmail, string myPhone = null)
  18.     {
  19.         var user = new ParseUser()
  20.         {
  21.             Username = myName,
  22.             Password = myPass,
  23.             Email = myEmail
  24.         };
  25.  
  26.         // other fields can be set just like with ParseObject
  27.         user["phone"] = myPhone;
  28.  
  29.         Task signUpTask = user.SignUpAsync();
  30.     }
  31.  
  32.     private void Login(string myName, string myPass)
  33.     {
  34.         ParseUser.LogInAsync(myName, myPass).ContinueWith(t =>
  35.         {
  36.             if (t.IsFaulted || t.IsCanceled)
  37.             {
  38.                 // The login failed. Check the error to see why.
  39.                 print(">> The login failed. Check the error to see why.");
  40.             }
  41.             else
  42.             {
  43.                 // Login was successful.
  44.                 print(">> Login was successful.");
  45.             }
  46.         });
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment