MSession PremiumLogin()
        {
            var login = new MLogin();

            // TryAutoLogin() read login cache file and check validation.
            // if cached session is invalid, it refresh session automatically.
            // but refreshing session doesn't always succeed, so you have to handle this.
            Console.WriteLine("Try Auto login");
            Console.WriteLine(login.SessionCacheFilePath);
            var response = login.TryAutoLogin();

            if (!response.IsSuccess) // cached session is invalid and failed to refresh token
            {
                Console.WriteLine("Auto login failed : {0}", response.Result.ToString());

                Console.WriteLine("Input mojang email : ");
                var email = Console.ReadLine();
                Console.WriteLine("Input mojang password : "******"failed to login. {0} : {1}", response.Result, response.ErrorMessage);
                    Console.ReadLine();
                    Environment.Exit(0);
                    return(null);
                }
            }

            return(response.Session);
        }
Beispiel #2
0
        private void SignIn(object sender, RoutedEventArgs e)
        {
            Progress.Value   = 0;
            Progress.Opacity = 100;
            var th = new Thread(new ThreadStart(delegate
            {
                var login       = new MLogin();
                string email    = "";
                string password = "";
                this.Dispatcher.Invoke(() =>
                {
                    email    = Email.Text;
                    password = userPassword.Password;
                });
                var result = login.Authenticate(email, password);
                if (result.Result == MLoginResult.Success)
                {
                    Session = result;
                    Dispatcher.BeginInvoke(new Action(delegate
                    {
                        LoginStatus.Foreground = Brushes.LightGreen;
                        LoginStatus.Text       = "Successful login! Transfering you to the main window...";
                        this.Hide();

                        MainWindowNew mw = new MainWindowNew(Session);
                        mw.Show();
                    }));
                }
                else
                {
                    Dispatcher.BeginInvoke(new Action(delegate
                    {
                        LoginStatus.Foreground = Brushes.Red;
                        LoginStatus.Text       = "Please check your email/password";
                        Progress.Opacity       = 0;
                    }));
                }
            }));

            if (ifOffline.IsChecked != false)
            {
                Regex r = new Regex("^[a-zA-Z0-9_]+$");
                if (r.IsMatch(Email.Text))
                {
                    MainWindowNew.ifOfflineMode = (bool)ifOffline.IsChecked;
                    MainWindowNew mw = new MainWindowNew(MSession.GetOfflineSession(Email.Text));
                    mw.Show();
                    this.Close();
                }
                else
                {
                    LoginStatus.Text = "Invalid characters in your username";
                    Progress.Opacity = 0;
                }
            }
            else
            {
                th.Start();
            }
        }
Beispiel #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtEmail.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                MessageBox.Show("Empty Textbox");
                return;
            }

            gMojangLogin.Enabled  = false;
            gOfflineLogin.Enabled = false;

            var th = new Thread(new ThreadStart(delegate
            {
                var result = login.Authenticate(txtEmail.Text, txtPassword.Text);
                if (result.Result == MLoginResult.Success)
                {
                    MessageBox.Show("Login Success"); // Success Login
                    Invoke(new Action(() =>
                    {
                        UpdateSession(result.Session);
                    }));
                }
                else
                {
                    MessageBox.Show(result.Result.ToString() + "\n" + result.ErrorMessage); // Failed to login. Show error message
                    Invoke(new Action(() =>
                    {
                        gMojangLogin.Enabled  = true;
                        gOfflineLogin.Enabled = true;
                    }));
                }
            }));

            th.Start();
        }
        private void Btn_Login_Click(object sender, EventArgs e)
        {
            // 로그인 버튼 눌렀을때
            // 로그인함

            Btn_Login.Enabled = false;
            if (Txt_Pw.Text == "")
            {
                //MessageBox.Show("배포용. 복돌기능 막혀잇습니다.");
                session = MSession.GetOfflineSession(Txt_Email.Text);
                MessageBox.Show("Offline login Success : " + Txt_Email.Text);
            }
            else
            {
                var th = new Thread(new ThreadStart(delegate
                {
                    var login  = new MLogin();
                    var result = login.Authenticate(Txt_Email.Text, Txt_Pw.Text);
                    if (result.Result == MLoginResult.Success)
                    {
                        MessageBox.Show("Login Success : " + result.Username);
                        session = result;
                    }
                    else
                    {
                        MessageBox.Show(result.Result.ToString() + "\n" + result.Message);
                        Invoke((MethodInvoker) delegate { Btn_Login.Enabled = true; });
                    }
                }));
                th.Start();
            }
        }
Beispiel #5
0
        public MSession Login(string loginEmail, string LoginPass, bool ifPremium)
        {
            var session = new MSession();

            if (ifPremium)
            {
                var login = new MLogin();
                session = login.TryAutoLogin();
                session = login.Authenticate(loginEmail, LoginPass);
                if (session.Result != MLoginResult.Success)
                {
                    LoggerUpdate("[Auth]" + "Unsuccessful Login");
                    return(null);
                }
                else
                {
                    LoggerUpdate("[Auth] Successful Login");
                }
                accessToken = session.AccessToken;
            }
            else
            {
                session = MSession.GetOfflineSession(offlineUsername);
            }
            return(session);
        }
Beispiel #6
0
        public bool Login(string email, string pwd)
        {
            //var rsp = login.TryAutoLogin();
            var rsp = login.Authenticate(email, pwd);

            if (!rsp.IsSuccess)
            {
                return(false);
            }

            se = rsp.Session;

            return(true);
        }
        public bool Login(MinecraftAccount Account)
        {
            MLogin Log = new MLogin();

            MLoginResponse Response = Log.Authenticate(Account.Email, Account.Password);

            if (!Response.IsSuccess)
            {
                return(false);
            }

            CurrentSession = Response.Session;
            return(true);
        }
Beispiel #8
0
        private void Btn_Login_Click(object sender, EventArgs e)
        {
            // Login
            if (Txt_User.Text == "")
            {
                MessageBox.Show("El campo usuario no puede estar vacio");
                return;
            }

            Btn_Login.Enabled = false;
            if (Txt_Pass.Text == "")
            {
                if (allowOffline)
                {
                    var login = new MLogin();
                    // session = MSession.GetOfflineSession(Txt_User.Text);
                    Session = login.offline(Txt_User.Text);
                    MessageBox.Show("Inicio pirata completado : " + Session.Username);
                }
                else
                {
                    MessageBox.Show("La contraseña no puede estar vacia");
                    Btn_Login.Enabled = true;
                    return;
                }
            }
            else
            {
                var th = new Thread(new ThreadStart(delegate
                {
                    var login  = new MLogin();
                    var result = login.Authenticate(Txt_User.Text, Txt_Pass.Text);
                    if (result.Result == MLoginResult.Success)
                    {
                        MessageBox.Show("Inicio completado : " + result.Username);
                        Session = result;
                    }
                    else
                    {
                        MessageBox.Show(result.Result.ToString() + "\n" + result.Message);
                        Invoke((MethodInvoker) delegate { Btn_Login.Enabled = true; });
                    }
                }));
                th.Start();
            }
        }
Beispiel #9
0
        public MSession LoginToMinecraft(string email, string password)
        {
            MLogin login = new MLogin();

            MSession session = login.Authenticate(email, password);

            if (session.Result != MLoginResult.Success)
            {
                throw new Exception(session.Result.ToString());
            }

            Properties.Settings.Default.email    = email;
            Properties.Settings.Default.password = password;
            Properties.Settings.Default.Save();

            return(session);
        }
        public static bool AuthenticateLogin(string username, string password)
        {
            var login  = new MLogin();
            var result = login.Authenticate(username, password);

            if (result.Result == MLoginResult.Success)
            {
                Console.WriteLine("Login Success : " + result.Username);
                GADD_Application.Properties.Settings.Default.username = username;
                GADD_Application.Properties.Settings.Default.password = password;
                Properties.Settings.Default.Save();
                Launch2.l2.session = result;
                return(true);
            }
            else
            {
                MessageBox.Show("Invalid Login, Please Try Again");
                return(false);
            }
        }
        public static void Login(FileManager.Modpacks modpack)
        {
            var login = new MLogin();

            string[] userData = File.ReadAllText("Launcher/BlockyCrafters/Login.txt").Split(' ');
            var      response = login.Authenticate(userData[0], userData[1]);

            if (!response.IsSuccess)
            {
                MCClient_Login mcClient = new MCClient_Login();
                mcClient.Show();
                mcClient.GetError($"Login Failed!\n" +
                                  "E-Mail or Password invalid!");
            }
            else
            {
                SESSION = response.Session;
                _       = LaunchGameAsync(modpack);
            }
        }
Beispiel #12
0
        MSession Login()
        {
            bool     premiumMode = false;
            MSession session;

            if (premiumMode)
            {
                Console.WriteLine("Try Auto login");

                var login = new MLogin();

                session = login.TryAutoLogin();
                if (session.Result != MLoginResult.Success)
                {
                    Console.WriteLine("Auto login failed : {0}", session.Result.ToString());

                    Console.WriteLine("Input mojang email : ");
                    var email = Console.ReadLine();
                    Console.WriteLine("Input mojang password : "******"failed to login. {0} : {1}", session.Result.ToString(), session.Message);
                        Console.ReadLine();
                        return(null);
                    }
                }
            }
            else
            {
                session = MSession.GetOfflineSession("tester123");
            }

            Console.WriteLine("Success to login : {0} / {1} / {2}", session.Username, session.UUID, session.AccessToken);
            return(session);
        }
Beispiel #13
0
        private void Btn_Login_Click(object sender, EventArgs e)
        {
            // Login

            Btn_Login.Enabled = false;
            if (Txt_Pw.Text == "") // Offline Login
            {
                if (allowOffline)
                {
                    Session = MSession.GetOfflineSession(Txt_Email.Text);
                    MessageBox.Show("Offline login Success : " + Txt_Email.Text);
                }
                else
                {
                    MessageBox.Show("Password was empty");
                    Btn_Login.Enabled = true;
                    return;
                }
            }
            else // Online Login
            {
                var th = new Thread(new ThreadStart(delegate
                {
                    var login  = new MLogin();
                    var result = login.Authenticate(Txt_Email.Text, Txt_Pw.Text);
                    if (result.Result == MLoginResult.Success)
                    {
                        MessageBox.Show("Login Success : " + result.Username); // Success Login
                        Session = result;
                    }
                    else
                    {
                        MessageBox.Show(result.Result.ToString() + "\n" + result.Message); // Failed to login. Show error message
                        Invoke((MethodInvoker) delegate { Btn_Login.Enabled = true; });
                    }
                }));
                th.Start();
            }
        }