Пример #1
0
        protected override void OnInitialize()
        {
            Mst.Events.Invoke(MstEventKeys.showLoadingInfo, "Connecting to master... Please wait!");

            // If we want to use default credentials for signin or signup views
            if (useDefaultCredentials && Mst.Runtime.IsEditor)
            {
                var credentials = new MstProperties();
                credentials.Set(MstDictKeys.USER_NAME, defaultUsername);
                credentials.Set(MstDictKeys.USER_PASSWORD, defaultPassword);
                credentials.Set(MstDictKeys.USER_EMAIL, defaultEmail);

                Mst.Events.Invoke(MstEventKeys.setSignInDefaultCredentials, credentials);
                Mst.Events.Invoke(MstEventKeys.setSignUpDefaultCredentials, credentials);
            }

            Mst.Client.Auth.RememberMe = rememberUser;

            MstTimer.WaitForSeconds(0.5f, () =>
            {
                // Listen to connection events
                Connection.AddConnectionListener(OnClientConnectedToServer);
                Connection.AddDisconnectionListener(OnClientDisconnectedFromServer, false);

                if (!Connection.IsConnected && !Connection.IsConnecting)
                {
                    Connector.StartConnection();
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Sends sign up request to master server
        /// </summary>
        public virtual void SignUp(string username, string useremail, string userpassword)
        {
            Mst.Events.Invoke(MstEventKeys.showLoadingInfo, "Signing up... Please wait!");

            logger.Debug("Signing up... Please wait!");

            var credentials = new MstProperties();

            credentials.Set(MstDictKeys.USER_NAME, username);
            credentials.Set(MstDictKeys.USER_EMAIL, useremail);
            credentials.Set(MstDictKeys.USER_PASSWORD, userpassword);

            Mst.Client.Auth.SignUp(credentials, (isSuccessful, error) =>
            {
                Mst.Events.Invoke(MstEventKeys.hideLoadingInfo);

                if (isSuccessful)
                {
                    Mst.Events.Invoke(MstEventKeys.hideSignUpView);
                    Mst.Events.Invoke(MstEventKeys.showSignInView);
                    Mst.Events.Invoke(MstEventKeys.setSignInDefaultCredentials, credentials);

                    logger.Debug($"You have successfuly signed up. Now you may sign in");
                }
                else
                {
                    string outputMessage = $"An error occurred while signing up: {error}";
                    Mst.Events.Invoke(MstEventKeys.showOkDialogBox, new OkDialogBoxEventMessage(outputMessage, null));
                    logger.Error(outputMessage);
                }
            });
        }
Пример #3
0
        private static void ClientAuthSignUp(CommandArg[] args)
        {
            var credentials = new MstProperties();

            credentials.Set("username", args[0].String);
            credentials.Set("email", args[1].String);
            credentials.Set("password", args[2].String);

            Mst.Client.Auth.SignUp(credentials, (isSuccessful, error) =>
            {
                if (isSuccessful)
                {
                    Logs.Info($"You have successfuly signed up. Now you may sign in");
                }
                else
                {
                    Logs.Error($"An error occurred while signing up: {error}");
                }
            });
        }
Пример #4
0
        public override string ToString()
        {
            var properties = new MstProperties();

            properties.Set("Id", Id);
            properties.Set("Username", Username);
            properties.Set("Password", Password);
            properties.Set("Email", Email);
            properties.Set("PhoneNumber", PhoneNumber);
            properties.Set("FacebookId", Facebook);
            properties.Set("IsAdmin", IsAdmin);
            properties.Set("IsGuest", IsGuest);
            properties.Set("IsEmailConfirmed", IsEmailConfirmed);
            properties.Append(Properties);

            return(properties.ToString());
        }