示例#1
0
    /// <summary>
    /// Registers a new user.
    /// </summary>
    /// <param name="user">The user object.</param>
    /// <param name="callback">Callback.</param>
    public static void RegisterUser(LumosUser user, Action <bool> callback)
    {
        var endpoint = "/users/" + user.id;
        var payload  = new Dictionary <string, object>()
        {
            { "password", user.password }
        };

        LumosUnity.Util.AddToDictionaryIfNonempty(payload, "email", user.email);

        LumosRequest.Send(LumosSocial.instance, endpoint, LumosRequest.Method.PUT, payload,
                          success => {
            var info           = success as Dictionary <string, object>;
            user.authenticated = true;
            user.Update(info);
            _localUser = user;

            if (callback != null)
            {
                callback(true);
            }
        },
                          error => {
            if (callback != null)
            {
                callback(false);
            }
        });
    }
示例#2
0
	/// <summary>
	/// Registers a new user.
	/// </summary>
	/// <param name="user">The user object.</param>
	/// <param name="callback">Callback.</param>
	public static void RegisterUser (LumosUser user, Action<bool> callback)
	{
		var endpoint = "/users/" + user.id;
		var payload = new Dictionary<string, object>() {
			{ "password", user.password }
		};

		LumosUnity.Util.AddToDictionaryIfNonempty(payload, "email", user.email);

		LumosRequest.Send(LumosSocial.instance, endpoint, LumosRequest.Method.PUT, payload,
			success => {
				var info = success as Dictionary<string, object>;
				user.authenticated = true;
				user.Update(info);
				_localUser = user;

				if (callback != null) {
					callback(true);
				}
			},
			error => {
				if (callback != null) {
					callback(false);
				}
			});
	}
示例#3
0
    /// <summary>
    /// Registers the new user.
    /// </summary>
    static void RegisterNewUser()
    {
        if (username.Length < 1 || password.Length < 1 || email.Length < 1)
        {
            LumosSocialGUI.statusMessage = "Please fill in all the fields.";
            return;
        }

        if (password != passwordConfirmation)
        {
            LumosSocialGUI.statusMessage = "Please supply matching passwords.";
            return;
        }

        LumosSocialGUI.inProgress    = true;
        LumosSocialGUI.statusMessage = "Registering...";
        var user = new LumosUser(username, password);

        user.email = email;

        LumosSocial.RegisterUser(user,
                                 success => {
            LumosSocialGUI.inProgress = false;

            if (success)
            {
                LumosSocialGUI.statusMessage = null;
                LumosSocialGUI.HideWindow();
            }
            else
            {
                LumosSocialGUI.statusMessage = "There was a problem registering. Please try again.";
            }
        });
    }
示例#4
0
    /// <summary>
    /// Submits the username and password.
    /// </summary>
    static void SubmitLoginCredentials()
    {
        if (username.Length < 1)
        {
            LumosSocialGUI.statusMessage = "Please enter a username.";
            return;
        }

        if (password.Length < 1)
        {
            LumosSocialGUI.statusMessage = "Please enter a password.";
            return;
        }

        LumosSocialGUI.inProgress    = true;
        LumosSocialGUI.statusMessage = "Logging in...";
        var user = new LumosUser(username, password);

        Social.Active.Authenticate(user,
                                   success => {
            LumosSocialGUI.inProgress = false;

            if (success)
            {
                LumosSocialGUI.HideWindow();
                LumosSocialGUI.statusMessage = null;
            }
            else
            {
                LumosSocialGUI.statusMessage = "There was a problem signing in. Perhaps your username and password do not match.";
            }
        });
    }
	static void Login (LumosUser user)
	{
		user.Authenticate(success => {
            if (success) {
            	Debug.Log("Authenticated, assigned as Social.localUser");
        	} else {
            	Debug.LogError("Failed to authenticate");
        	}
			
			LumosSocialDemoCustomLoginGUI.LoginComplete(success);
        });
	}
	static void Register (LumosUser user)
	{
		LumosSocial.RegisterUser(user, success => {
            if (success) {
				PlayerPrefs.SetInt(hasRegisteredKey, 1);
                Debug.Log("Registered and authenticated, assigned as Social.localUser");
            } else {
                Debug.LogError("Unable to register user");
            }
			
			LumosSocialDemoCustomLoginGUI.RegistrationComplete(success);
        });
	}
示例#7
0
	/// <summary>
	/// Authenticates the given user.
	/// </summary>
	/// <param name="user">The user to authenticate.</param>
	/// <param name="callback">Callback.</param>
	public void Authenticate (ILocalUser user, Action<bool> callback)
	{
		user.Authenticate(
			success => {
				if (success) {
					_localUser = user as LumosUser;
				}

				if (callback != null) {
					callback(success);
				}
			});
	}
示例#8
0
    static void Login(LumosUser user)
    {
        user.Authenticate(success => {
            if (success)
            {
                Debug.Log("Authenticated, assigned as Social.localUser");
            }
            else
            {
                Debug.LogError("Failed to authenticate");
            }

            LumosSocialDemoCustomLoginGUI.LoginComplete(success);
        });
    }
示例#9
0
    /// <summary>
    /// Authenticates the given user.
    /// </summary>
    /// <param name="user">The user to authenticate.</param>
    /// <param name="callback">Callback.</param>
    public void Authenticate(ILocalUser user, Action <bool> callback)
    {
        user.Authenticate(
            success => {
            if (success)
            {
                _localUser = user as LumosUser;
            }

            if (callback != null)
            {
                callback(success);
            }
        });
    }
示例#10
0
    static void Register(LumosUser user)
    {
        LumosSocial.RegisterUser(user, success => {
            if (success)
            {
                PlayerPrefs.SetInt(hasRegisteredKey, 1);
                Debug.Log("Registered and authenticated, assigned as Social.localUser");
            }
            else
            {
                Debug.LogError("Unable to register user");
            }

            LumosSocialDemoCustomLoginGUI.RegistrationComplete(success);
        });
    }
    // Useful if:
	// 1. You want cross platform support (players will choose their usernames and passwords)
	// 2. You want to use leaderboards and friend lists
	// 3. You don't need cross platform support (the player will not know their password)
    public static void Authenticate (string username, string password, bool register)
    {
		var user = new LumosUser(username, password);
		
		// You could modify these functions to accept more user details and set them here.
		// Example: modify this function to accept an email address and assign it to user.email 
		// before registering. If you set an email when registering a user, you can optionally use 
		// our welcome email feature (configurable on the Lumos Social dashboard).
		// You can also set arbitrary information using user.other. 
		// All user details can be updated after registration except for the username.
		
        // Register new user
        if (register) {
            Register(user);
        // Login with a registered user
        } else {
            Login(user);
        }
    }
示例#12
0
    // Useful if:
    // 1. You want cross platform support (players will choose their usernames and passwords)
    // 2. You want to use leaderboards and friend lists
    // 3. You don't need cross platform support (the player will not know their password)
    public static void Authenticate(string username, string password, bool register)
    {
        var user = new LumosUser(username, password);

        // You could modify these functions to accept more user details and set them here.
        // Example: modify this function to accept an email address and assign it to user.email
        // before registering. If you set an email when registering a user, you can optionally use
        // our welcome email feature (configurable on the Lumos Social dashboard).
        // You can also set arbitrary information using user.other.
        // All user details can be updated after registration except for the username.

        // Register new user
        if (register)
        {
            Register(user);
            // Login with a registered user
        }
        else
        {
            Login(user);
        }
    }
示例#13
0
	public void SetLocalUser (LumosUser user)
	{
		_localUser = user;
	}
示例#14
0
 public void SetLocalUser(LumosUser user)
 {
     _localUser = user;
 }
示例#15
0
	/// <summary>
	/// Submits the username and password.
	/// </summary>
	static void SubmitLoginCredentials ()
	{
		if (username.Length < 1) {
			LumosSocialGUI.statusMessage = "Please enter a username.";
			return;
		}

		if (password.Length < 1) {
			LumosSocialGUI.statusMessage = "Please enter a password.";
			return;
		}

		LumosSocialGUI.inProgress = true;
		LumosSocialGUI.statusMessage = "Logging in...";
		var user = new LumosUser(username, password);

		Social.Active.Authenticate(user,
			success => {
				LumosSocialGUI.inProgress = false;

				if (success) {
					LumosSocialGUI.HideWindow();
					LumosSocialGUI.statusMessage = null;
				} else {
					LumosSocialGUI.statusMessage = "There was a problem signing in. Perhaps your username and password do not match.";
				}
			});
	}