コード例 #1
0
ファイル: Login (2).cs プロジェクト: JohnBoyB/JHack
        //User login and generating of new rsa keypair if not exists
        private void but_Login_Click(object sender, EventArgs e)
        {
            //define local variables from the user inputs
            string username = txb_Username.Text;
            string password = txb_Password.Text;
            string ppk      = @"c:\crypto\rsakeys\" + System.Environment.MachineName + ".ppk";
            string pub      = @"c:\crypto\rsakeys\" + System.Environment.MachineName + ".pub";

            //if debug mode you can login with username 1 and password 1
#if DEBUG
            // creating an easy login for testing solong no webAPI exists
            FormLogin login = new FormLogin("1", "1");
            //check if eligible to be logged in
            if (login.IsLoggedIn(username, password))
            {
                Client Form1 = new Client();
                Form1.Show();
                if (!File.Exists(ppk) && !File.Exists(pub))
                {
                    crypto.Keys(System.Environment.MachineName + ".pub", System.Environment.MachineName + ".ppk");
                }
                this.Hide();
            }

            //if release mode use AuthO with JASON API to connect to the server and recive a jwt token
#else
            ApiLoginOperations ops = new ApiLoginOperations();
            User user = ops.AuthenticateUser(username, password);
            if (user == null)
            {
                MessageBox.Show("Invalid username or password");
                return;
            }

            Globals.LoggedInUser = user;
            MessageBox.Show("Login successful");
            Client Form1 = new Client();
            Form1.Show();
            if (!File.Exists(ppk) && !File.Exists(pub))
            {
                crypto.Keys(System.Environment.MachineName + ".pub", System.Environment.MachineName + ".ppk");
            }
            this.Hide();

            //ToDo Logging
#endif
        }
コード例 #2
0
ファイル: Regestration.cs プロジェクト: JohnBoyB/JHack
        //register a user over the ApiLoginOperations with username, password & email
        private void but_Regestration_Click(object sender, EventArgs e)
        {
            try
            {
                string username = txb_Username.Text;
                string password = txb_Password.Text;
                string eMail    = txb_EMail.Text;

                ApiLoginOperations ops = new ApiLoginOperations();
                User user = ops.RegisterUser(username, password, eMail);
                if (username != String.Empty && password != String.Empty && eMail != String.Empty)
                {
                    if (user == null)
                    {
                        //To present a successful registration
                        //MessageBox.Show("There was an error");
                        MessageBox.Show("User account registered", "Successfully");
                        log.Error("Registration failed");

                        Login Login = new Login();
                        this.Hide();
                        Login.ShowDialog();
                        this.Close();

                        return;
                    }

                    Globals.LoggedInUser = user;
                    MessageBox.Show("Registration successful");
                    Login login = new Login();
                    login.Show();
                    this.Hide();
                    log.Info("Registration successful");
                }
                else
                {
                    MessageBox.Show("Please fill in all fields", "Error");
                    log.Error("Registration form was not filled in correctly");
                }
            }

            catch
            {
                log.Error("Registration failed");
            }
        }
コード例 #3
0
ファイル: Login.cs プロジェクト: JohnBoyB/JHack
        //User login and generating of new rsa keypair if not exists
        private void but_Login_Click(object sender, EventArgs e)
        {
            //define local variables from the user inputs
            string username = txb_Username.Text;
            string password = txb_Password.Text;

            //if debug mode you can login with username 1 and password 1
#if DEBUG
            // creating an easy login for testing solong no webAPI exists
            Login login = new Login("*****@*****.**", "test123");
            //check if eligible to be logged in
            if (login.IsLoggedIn(username, password))
            {
                Client Form1 = new Client();
                this.Hide();
                Form1.ShowDialog();
                this.Close();
            }

            //if release mode use AuthO with JASON API to connect to the server and recieve a jwt token
#else
            ApiLoginOperations ops = new ApiLoginOperations();
            User user = ops.AuthenticateUser(username, password);
            if (user == null)
            {
                MessageBox.Show("Invalid username or password");
                return;
            }

            Globals.LoggedInUser = user;
            MessageBox.Show("Login successful");
            Client Form1 = new Client();
            this.Hide();
            Form1.ShowDialog();
            this.Close();

            log.Info("asymKeys generated");
#endif
        }
コード例 #4
0
        //register a user over the ApiLoginOperations with username, password & email
        private void but_Regestration_Click(object sender, EventArgs e)
        {
            try
            {
                string username = txb_Username.Text;
                string password = txb_Password.Text;
                string eMail    = txb_EMail.Text;

                ApiLoginOperations ops = new ApiLoginOperations();
                User user = ops.RegisterUser(username, password, eMail);
                if (username != String.Empty && password != String.Empty && eMail != String.Empty)
                {
                    if (user == null)
                    {
                        //Create more than one error message
                        MessageBox.Show("There was an error");
                        //ToDo Logging
                        return;
                    }

                    Globals.LoggedInUser = user;
                    MessageBox.Show("Registration successful");
                    FormLogin login = new FormLogin();
                    login.Show();
                    this.Hide();
                    //ToDo Logging
                }
                else
                {
                    MessageBox.Show("Please file all fileds", "Error");
                    //ToDo Logging
                }
            }

            catch
            {
                //ToDo Logging
            }
        }