Beispiel #1
0
        public HomeModule()
        {
            // Gacha
            Post["/Gacha"] = parameters =>
            {
                var jsonFromClient = this.Request.Body.AsString();

                var controller = new GachaController();
                var ret        = controller.Perform(jsonFromClient);

                return(ret);
            };

            // Sign In
            Post["/SignIn"] = parameters =>
            {
                var jsonFromClient = this.Request.Body.AsString();

                var controller = new SignInController();
                var ret        = controller.Perform(jsonFromClient);

                return(ret);
            };

            // Log In
            Post["/LogIn"] = parameters =>
            {
                var jsonFromClient = this.Request.Body.AsString();
                var controller     = new LogInController();
                var ret            = controller.Perform(jsonFromClient);

                return(ret);
            };
        }
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            try
            {
                AuthenticationHeaderValue authValue = actionContext.Request.Headers.Authorization;

                if (authValue != null && !String.IsNullOrWhiteSpace(authValue.Parameter))
                {
                    using (DB context = new DB())
                    {
                        if (context.Sesje.Any(s => s.ID_Sesji == authValue.Parameter))
                        {
                            var sesja = context.Sesje.FirstOrDefault(s => s.ID_Sesji == authValue.Parameter);
                            if (LogInController.konwertujNaStempel(DateTime.Now) < sesja.Data_waznosci)
                            {
                                var firstOrDefault = context.Rolee.FirstOrDefault(r => r.ID_Roli == sesja.ID_Roli);
                                if (firstOrDefault != null)
                                {
                                    var rolesPermissions = firstOrDefault.Uprawnienie_Rola;
                                    if (rolesPermissions != null)
                                    {
                                        int idUprawnienia = context.Uprawnienia.FirstOrDefault(p => (p.Nazwa_tabeli + "_" + p.Instrukcja) == Roles).ID_Uprawnienia;
                                        if (rolesPermissions.All(rp => rp.ID_Uprawnienia != idUprawnienia))
                                        {
                                            actionContext.Response =
                                                actionContext.Request.CreateResponse(HttpStatusCode.Forbidden);
                                        }
                                    }
                                    else
                                    {
                                        actionContext.Response =
                                            actionContext.Request.CreateResponse(HttpStatusCode.Forbidden);
                                    }
                                }
                                else
                                {
                                    actionContext.Response =
                                        actionContext.Request.CreateResponse(HttpStatusCode.Forbidden);
                                }
                            }
                            else
                            {
                                actionContext.Response =
                                    actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                            }
                        }
                        else
                        {
                            actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                        }
                    }
                }
            }
            catch (Exception)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                return;
            }
        }
 public void SetUp()
 {
     _userService        = new Mock <IUserService>();
     _accessgroupService = new Mock <IAccessGroupService>();
     _subject            = new LogInController(_userService.Object, _accessgroupService.Object);
     _httpRequest        = new Mock <HttpRequestBase>();
     _httpContext        = new Mock <HttpContextBase>();
     _httpContext.Setup(c => c.Request).Returns(_httpRequest.Object);
     _subject.ControllerContext = new ControllerContext(_httpContext.Object, new RouteData(), _subject);
 }
Beispiel #4
0
        public void Login()
        {
            CUSTOMER customerModel = new CUSTOMER();

            /* customerModel.USERNAME = "******";
             * customerModel.PASSWORD = "******";
             * customerModel.FIRSTNAME = "hjk";
             * customerModel.IBAN = "asd";
             * customerModel.LASTNAME = "asdf";
             */
            LogInController controller = new LogInController();

            ViewResult result = controller.Login(customerModel) as ViewResult;

            Assert.AreEqual("LOGGED IN", result.ViewBag.LoggedMessage);
        }
Beispiel #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            LogInController LoadInformation = new LogInController();

            if (LoadInformation.Regist(textBox3.Text, textBox4.Text) == true)
            {
                MessageBox.Show("Regist successful !!!", "Announce:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                panel6.Hide();
                textBox3.Text = "Username";
                textBox4.Text = "Password";
                textBox4.UseSystemPasswordChar = false;
            }
            else
            {
                MessageBox.Show("This Username Unavailable", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected virtual void Submit_Clicked(object sender, EventArgs e)
        {
            User            user            = new User(userId.Text, password.Text);
            SqlConnection   sqlConnection   = new SqlConnection(@"Data Source = KOWSALYA\SQLSERVER; Initial Catalog = master; User ID = sa; Password = gowtham");
            LogInController logInController = new LogInController();
            int             retRows         = logInController.LogIn(user, sqlConnection);

            if (retRows == 0)
            {
                Response.Write("Incorrect Username or Password");
            }
            else
            {
                string message = "Logged in successfully.";
                string script  = "window.onload = function(){ alert('";
                script += message;
                script += "')};";
                ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
            }
            //    {
            //        using (SqlCommand sqlCommand = new SqlCommand("Registration", sqlConnection))
            //        {
            //            sqlCommand.CommandType = CommandType.StoredProcedure;
            //            sqlConnection.Open();
            //            sqlCommand.Parameters.Add(new SqlParameter("@userId", TextBox1.Text));
            //            sqlCommand.Parameters.Add(new SqlParameter("@mobileNumber", TextBox2.Text));
            //            sqlCommand.Parameters.Add(new SqlParameter("@password", TextBox3.Text));
            //            sqlCommand.Parameters.Add(new SqlParameter("@userType", TextBox4.Text));
            //            int retRows = sqlCommand.ExecuteNonQuery();
            //            if (retRows >= 1)
            //            {
            //                string message = "Registered successfully.";
            //                string script = "window.onload = function(){ alert('";
            //                script += message;
            //                script += "')};";
            //                ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
            //            }
            //            else
            //            {
            //                Response.Write("Not Registered...");
            //            }
            //            sqlCommand.Dispose();
            //            sqlConnection.Close();
            //        }
            //    }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            LogInController LoadInformation = new LogInController();

            if (LoadInformation.LogIn(textBox1.Text, textBox2.Text) == true)
            {
                NotePage NotePage = new NotePage(textBox1.Text);
                this.Hide();
                NotePage.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Username or Password does not correct", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Text = "Username";
                textBox2.Text = "Password";
            }
        }
Beispiel #8
0
        private void logInButton_Click(object sender, EventArgs e)
        {
            string users = userTextBox.Text;
            string pass  = passTextBox.Text;

            TcpClientChannel channel = new TcpClientChannel();

            ChannelServices.RegisterChannel(channel, false);
            IService service = (IService)(Activator.GetObject(typeof(IService),
                                                              "tcp://localhost:9999/IService"
                                                              ));

            LogInController logIn = new LogInController(users, pass, service);

            LogInfo info = logIn.getAccount();

            if (info == null)
            {
                //TODO show error
                ChannelServices.UnregisterChannel(channel);
                return;
            }


            if (info.type.Equals("Doctor"))
            {
                //TODO Doctor GUI
            }

            if (info.type.Equals("Donation"))
            {
                Common.Model.DonationCenter donationCenter     = service.GetOneFromDatabase <Common.Model.DonationCenter>(info.varId);
                DonationCenterController    donationController = new DonationCenterController(service, donationCenter);

                this.Hide();
                new DonationCenterGUI(donationController).ShowDialog();
            }

            if (info.type.Equals("Donor"))
            {
                //TODO Donor GUI
            }
        }
Beispiel #9
0
        public Email(string Header, string Content, string NoteDraw, string NotePic) : this()
        {
            LogInController GetEmail = new LogInController();

            EHeader       = Header;
            EContent      = Content;
            ENoteDraw     = NoteDraw;
            ENotePic      = NotePic;
            textBox1.Text = EContent;
            textBox5.Text = EHeader;
            if (System.IO.File.Exists(ENoteDraw))
            {
                pictureBox1.BackgroundImage = Image.FromFile(String.Format(ENoteDraw));
            }
            if (System.IO.File.Exists(ENotePic))
            {
                pictureBox2.BackgroundImage = Image.FromFile(String.Format(ENotePic));
            }
        }
        public int CheckValidity(LogInController lc)
        {
            SakiDataSet ds    = new SakiDataSet();
            string      type  = "";
            string      uName = lc.UserName;
            string      pwd   = lc.Password;

            switch (lc.TypeOfUser)
            {
            case 0: type = "RECEPTION";
                break;

            case 1: type = "COORDINATOR";
                break;

            case 2: type = "CASHIER";
                break;

            case 3: type = "ADMINISTRATOR";
                break;
            }


            DataTable dt = new DataTable();

            dt = ds.Tables["AccessControlTable"];

            DataRow[] result = dt.Select("AccessType like '%" + type + "%'");
            //DataRow[] result = dt.Select("UserName like '%"+uName+"%'");
            //DataRow[] result = dt.Select("Password like '%"+pwd+"%'");


            if (result.Length != 0)
            {
                return(1);
            }

            else
            {
                return(-1);
            }
        }
        protected virtual void Submit_Clicked(object sender, EventArgs e)
        {
            User            user            = new User(userId.Text, password.Text);
            SqlConnection   sqlConnection   = new SqlConnection(@"Data Source = KOWSALYA\SQLSERVER; Initial Catalog = master; User ID = sa; Password = gowtham");
            LogInController logInController = new LogInController();
            int             retRows         = logInController.LogIn(user, sqlConnection);

            if (retRows == 0)
            {
                Response.Write("Incorrect Username or Password");
            }
            else
            {
                string message = "Logged in successfully.";
                string script  = "window.onload = function(){ alert('";
                script += message;
                script += "')};";
                ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
            }
        }
Beispiel #12
0
 public void Setup()
 {
     _uut            = new LogInController();
     _logInInfo      = Substitute.For <LogInInfo>();
     _patientInfoDto = Substitute.For <PatientInfoDTO>();
 }
Beispiel #13
0
        /* Constructor */

        public LogInPanel()
        {
            controller = new LogInController(this);

            // Init dimensions
            this.formComponentWidth = this.formContainerWidth - 2 * this.formContainerPadding;
            Padding headerLabelMargins = new Padding(this.formContainerPadding);
            Padding txtBoxMargins      = new Padding(this.formContainerPadding, this.formContainerPadding, 0, 0);
            Padding labelMargins       = new Padding(this.formContainerPadding, this.formContainerPadding, 0, 0);

            // Init Panel
            this.Panel           = new Panel();
            this.Panel.AutoSize  = true;
            this.Panel.Location  = new Point(0, 0);
            this.Panel.Name      = "logInPanel";
            this.Panel.Size      = new Size(Dimensions.PANEL_WIDTH, Dimensions.PANEL_HEIGHT);
            this.Panel.BackColor = Colors.ALTO;
            this.Panel.Visible   = true;

            // Init log in form container
            int formContainerX = Panels.getComponentStartingPositionX(Dimensions.PANEL_WIDTH, formContainerWidth);
            int formContainerY = Panels.getComponentStartingPositionY(Dimensions.PANEL_HEIGHT, formContainerHeight);

            this.formContainer           = new TableLayoutPanel();
            this.formContainer.Location  = new Point(formContainerX, formContainerY);
            this.formContainer.Name      = "formContainer";
            this.formContainer.Size      = new Size(formContainerWidth, formContainerHeight);
            this.formContainer.BackColor = Colors.WHITE;

            this.Panel.Controls.Add(this.formContainer);

            // Init header label
            this.headerLabel           = new Label();
            this.headerLabel.Width     = this.formComponentWidth;
            this.headerLabel.Height    = 60;
            this.headerLabel.Text      = "Identifikimi";
            this.headerLabel.Font      = new Font(Fonts.primary, 32, FontStyle.Bold);
            this.headerLabel.ForeColor = Colors.MALACHITE;
            this.headerLabel.TextAlign = ContentAlignment.MiddleCenter;
            this.headerLabel.Margin    = headerLabelMargins;

            this.formContainer.Controls.Add(headerLabel, 0, 0);

            // Init email label
            this.emailLabel           = new Label();
            this.emailLabel.Width     = this.formComponentWidth;
            this.emailLabel.Height    = this.labelHeight;
            this.emailLabel.Text      = "Email";
            this.emailLabel.Font      = new Font(Fonts.primary, 12, FontStyle.Regular);
            this.emailLabel.ForeColor = Colors.DOVE_GRAY;
            this.emailLabel.TextAlign = ContentAlignment.BottomLeft;
            this.emailLabel.Margin    = labelMargins;

            this.formContainer.Controls.Add(emailLabel, 0, 1);

            // Init email text box
            this.EmailTextBox        = new TextBox();
            this.EmailTextBox.Width  = this.formComponentWidth;
            this.EmailTextBox.Font   = new Font(Fonts.primary, 12, FontStyle.Regular);
            this.EmailTextBox.Margin = txtBoxMargins;

            this.formContainer.Controls.Add(EmailTextBox, 0, 2);

            // Init password label
            this.passwordLabel           = new Label();
            this.passwordLabel.Width     = this.formComponentWidth;
            this.passwordLabel.Height    = this.labelHeight;
            this.passwordLabel.Text      = "Fjalëkalimi";
            this.passwordLabel.Font      = new Font(Fonts.primary, 12, FontStyle.Regular);
            this.passwordLabel.ForeColor = Colors.DOVE_GRAY;
            this.passwordLabel.TextAlign = ContentAlignment.BottomLeft;
            this.passwordLabel.Margin    = labelMargins;

            this.formContainer.Controls.Add(passwordLabel, 0, 3);

            // Init password text box
            Padding passwordTxtBoxMargins = new Padding(this.formContainerPadding, this.formContainerPadding, 0, 50);

            this.PasswordTxtBox = new TextBox();
            this.PasswordTxtBox.PasswordChar = '*';
            this.PasswordTxtBox.Width        = this.formComponentWidth;
            this.PasswordTxtBox.Font         = new Font(Fonts.primary, 12, FontStyle.Regular);
            this.PasswordTxtBox.Margin       = passwordTxtBoxMargins;

            this.formContainer.Controls.Add(PasswordTxtBox, 0, 4);

            // Init log in button
            Padding logInButtonMargins = new Padding(this.formContainerPadding, this.formContainerPadding, 100, 0);

            this.logInBtn      = new Button();
            this.logInBtn.Name = "logInBtn";
            this.logInBtn.Size = new Size(formComponentWidth, 60);
            this.logInBtn.Text = "HYR";
            this.logInBtn.UseVisualStyleBackColor = true;
            this.logInBtn.Font       = new Font(Fonts.primary, 12, FontStyle.Bold);
            this.logInBtn.ForeColor  = Colors.WHITE;
            this.logInBtn.BackColor  = Colors.MALACHITE;
            this.logInBtn.FlatStyle  = FlatStyle.Flat;
            this.logInBtn.Margin     = logInButtonMargins;
            this.logInBtn.Image      = Image.FromFile("../../Resources/done.png");
            this.logInBtn.ImageAlign = ContentAlignment.MiddleLeft;
            this.logInBtn.Click     += new EventHandler(onLogInBtnClicked);

            this.formContainer.Controls.Add(this.logInBtn, 0, 6);
        }
 static void Control()
 {
     LogInController controller = new LogInController();
 }