Пример #1
0
        //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
        //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
        }