Пример #1
0
        protected void btnPasswordUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text && !(txtConfirmPassword.Text == "" && "" == txtNewPassword.Text))
            {
                AccountConnection account = new AccountConnection();
                Qaelo.Models.ShopOwnerModel.ShopOwner s = (Qaelo.Models.ShopOwnerModel.ShopOwner)Session["SHOPOWNER"];

                //Test password

                if (account.correctShopOwner(s.Email, Secrecy.HashPassword(txtCurrentPassword.Text)) && new ShopConnection().updatePassword(s.Id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
        public int AddMember(User u)
        {
            var member = new UserTable
            {
                FirstName  = u.name,
                LastName   = u.lastname,
                EmailAd    = u.email,
                CellNumber = u.phonenumber,
                Password   = Secrecy.HashPassword(u.password),
                active     = u.active,
                Usertype   = u.usertype
            };

            db.UserTables.InsertOnSubmit(member);
            try
            {
                db.SubmitChanges();
                return(1);
            }
            catch (Exception e)
            {
                e.GetBaseException();
                return(-1);
            }
        }
Пример #3
0
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;
            string cPassword = txtConfirmPassword.Text;

            if (!password.Equals(cPassword))
            {
                lblError.Text    = "Make sure the passwords you enter are the same";
                lblError.Visible = true;
            }
            else
            {
                bool passwordChangeSuccessful, a;
                lc.ChangeEmployerPassword(username, Secrecy.HashPassword(password), out passwordChangeSuccessful, out a);
                if (!passwordChangeSuccessful)
                {
                    lc.ChangeJobSeekerPassword(username, Secrecy.HashPassword(password), out passwordChangeSuccessful, out a);
                    if (!passwordChangeSuccessful)
                    {
                        lblError.Text    = "Make sure you enter the correct username";
                        lblError.Visible = true;
                    }
                    else
                    {
                        Response.Redirect("LoginPage.aspx");
                    }
                }
                else
                {
                    Response.Redirect("LoginPage.aspx");
                }
            }
        }
Пример #4
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text)
            {
                AccountConnection account           = new AccountConnection();
                Qaelo.Models.SocietyModel.Society s = (Qaelo.Models.SocietyModel.Society)Session["SOCIETY"];

                //Test password

                if (account.correctSociety(s.Email, Secrecy.HashPassword(txtCurrentPassword.Text)) && account.updatePassword(s.Id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
        //line divider added
        //*************************************************************************************************************

        public bool resetPass(int email, string password)
        {
            var user = (from p in db.Clients
                        where p.Email.Equals(email)
                        select p).FirstOrDefault();

            if (Secrecy.HashPassword(password).Equals(user.Password))
            {
                return(false);
            }
            else
            {
                user.Password = Secrecy.HashPassword(password);
                try
                {
                    db.SubmitChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    ex.GetBaseException();
                    return(false);
                }
            }
        }
Пример #6
0
        public int Register(User FFieldUser)
        {
            var NewUser = new User
            {
                first_name   = FFieldUser.first_name,
                last_name    = FFieldUser.last_name,
                email        = FFieldUser.email,
                phone_number = FFieldUser.phone_number,
                address      = FFieldUser.address,
                user_type    = FFieldUser.user_type,
                active       = Convert.ToInt32(FFieldUser.active),
                password     = Secrecy.HashPassword(FFieldUser.password),
                zip_code     = FFieldUser.zip_code,
                city         = FFieldUser.city,
                province     = FFieldUser.province
            };

            db.Users.InsertOnSubmit(NewUser);

            try
            {
                db.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                ex.GetBaseException();
                return(-1);
            }
        }
        //line divider added
        //*************************************************************************************************************

        public bool UserRegister(User user)
        {
            var addUser = new Client
            {
                Title     = user.Title,
                Name      = user.name,
                Surname   = user.surname,
                Contacts  = user.contacs,
                Email     = user.email,
                Username  = user.username,
                Password  = Secrecy.HashPassword(user.password),
                Address1  = user.address1,
                Address2  = user.address2,
                City      = user.city,
                ZipCode   = user.ZipCode,
                Province  = user.province,
                Active    = user.active,
                User_type = user.type
            };

            db.Clients.InsertOnSubmit(addUser);
            try
            {
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                ex.GetBaseException();
                return(false);
            }
        }
Пример #8
0
        public void Post([FromBody] CaseViewModel value)
        {
            //db.Users.Add(new Models.User(0, value.FullName, value.IDNumber, value.UserType, password));

            Random random         = new Random();
            string randomPassword = random.Next(500, 5000).ToString();//Generate a random password

            value.VictimPassword = Secrecy.HashPassword(randomPassword);
            string caseNo = RandomString(9);
            //Send Case No and Password to the Victim

            //Add a case
            //Get Capturer
            User capturer = db.Users.FirstOrDefault(e => e.IDNumber == value.CapturerIdNo);

            if (capturer != null)
            {
                // db.Users.FirstOrDefault(e => e.IDNumber == value.CapturerIdNo).Cases.Add(new Case(0, caseNo, DateTime.Now, value.Description, value.Media, value.VictimID, "", value.CaseType, value.VictimFullName, value.CapturerIdNo, Status.CASE_PENDING));

                capturer.AddNewCase(new Case(0, caseNo, DateTime.Now, value.Description, value.Media, value.VictimID, RandomAssignACase(), value.CaseType, value.VictimFullName, value.CapturerIdNo, Status.CASE_PENDING));

                capturer.addNewVictims(new Victim(0, value.VictimFullName, value.VictimID, value.VictimPassword, value.VictimAddress, value.VictimGender, value.VictimCellNo, value.CapturerIdNo));

                string content = string.Format("Hi {0} Your Case Number is {1} And use your ID number to check ur case on our system", value.VictimFullName, caseNo);

                string decryp = "0027" + value.VictimCellNo.Substring(1, value.VictimCellNo.Length - 1);
                sendMessage(content, decryp, "New Case Created");
                db.SaveChanges();
            }
        }
Пример #9
0
        public int Register(User user)
        {
            var regQuery = context.Users.Where <User>(r => r.Email.Equals(user.Email)).FirstOrDefault();

            if (regQuery != null)
            {
                return(0); //Email already exist
            }

            var RegUser = new User
            {
                Name     = user.Name,
                LastName = user.LastName,
                Email    = user.Email,
                Password = Secrecy.HashPassword(user.Password)
            };

            context.Users.InsertOnSubmit(RegUser);

            try
            {
                context.SubmitChanges();
                return(1); //successfully created
            }
            catch (Exception ex)
            {
                ex.GetBaseException();
                return(-1); //Error something went wrong
            }
        }
Пример #10
0
        //adding a new user to the database
        public int Register(User details)
        {
            var NewUser = new UserTable
            {
                User_Name    = details.Name,
                User_Surname = details.surname,
                User_Email   = details.email,
                Password     = Secrecy.HashPassword(details.pass),
                Active       = details.active,
                UserType     = details.type
            };

            db.UserTables.InsertOnSubmit(NewUser);
            try
            {
                db.SubmitChanges();
                return(1);
            }
            //Error Handling
            catch (Exception ex)
            {
                ex.GetBaseException();
                return(-1);
            }
        }
Пример #11
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtConfirmPassword.Text == txtNewPassword.Text && !(txtConfirmPassword.Text == "" && "" == txtNewPassword.Text))
            {
                AccountConnection account = new AccountConnection();

                Manager s = (Manager)(Session["PROPERTYMANAGER"]);

                //Test password

                if (account.correctPropertyManager(s.email, Secrecy.HashPassword(txtCurrentPassword.Text)) && new ManagerConnection().updateManagerPassword(s.id, Secrecy.HashPassword(txtNewPassword.Text), Secrecy.HashPassword(txtCurrentPassword.Text)))
                {
                    lblSuccess.Text      = "Successfuly Updated Password";
                    lblErrorMessage.Text = "";
                }
                else
                {
                    lblErrorMessage.Text = "Incorrect Current Password";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "New password and confirm Password Do not match ";
                lblSuccess.Text      = "";
            }
        }
Пример #12
0
        public void Post([FromBody] UserViewModel value)
        {
            string password = Secrecy.HashPassword(value.Password);

            db.Users.Add(new Models.User(0, value.FullName, value.IDNumber, value.UserType, password));

            db.SaveChanges();
        }
Пример #13
0
        public void closeAcc(string Email, string Password)
        {
            var userQuery = context.Users.Where <User>(u => u.Email.Equals(Email) &&
                                                       u.Password.Equals(Secrecy.HashPassword(Password))).FirstOrDefault();

            context.Users.DeleteOnSubmit(userQuery);
            context.SubmitChanges();
        }
Пример #14
0
        public void EditUser(User appUser)
        {
            var editUser = context.Users.Where <User>(u => u.Id.Equals(appUser.Id)).FirstOrDefault();

            if (editUser != null)
            {
                editUser.Name        = appUser.Name;
                editUser.LastName    = appUser.LastName;
                editUser.Password    = Secrecy.HashPassword(appUser.Password);
                editUser.Email       = appUser.Email;
                editUser.Description = appUser.Description;
            }
            context.SubmitChanges();
        }
Пример #15
0
        public bool Login(string Email, string Password)
        {
            bool isRegistered = false;

            var userQuery = context.Users.Where <User>(u => u.Email.Equals(Email) &&
                                                       u.Password.Equals(Secrecy.HashPassword(Password))).FirstOrDefault();

            if (userQuery != null)
            {
                isRegistered = true;
            }

            return(isRegistered);
        }
Пример #16
0
        public bool Login(string email, string password)
        {
            var login = (from p in db.Clients
                         where p.Email.Equals(email) && p.Password.Equals(Secrecy.HashPassword(password))
                         select p).FirstOrDefault();

            if (login != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        public bool Registered(string Email, string Password)
        {
            dynamic UserReg = (from Reg in db.Users
                               where Reg.email.Equals(Email) &&
                               Reg.password.Equals(Secrecy.HashPassword(Password))
                               select Reg).FirstOrDefault();

            if (UserReg == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public bool Registerd(string email, string password)
        {
            dynamic check = (from R in db.UserTables
                             where R.EmailAd.Equals(email) &&
                             R.Equals(Secrecy.HashPassword(password))
                             select R).FirstOrDefault();

            if (check != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public int Login(string EmailS, string PassWordS)
        {
            var check = (from d in db.UserTables
                         where d.EmailAd.Equals(EmailS) &&
                         d.active.Equals(1) &&
                         d.Password.Equals(Secrecy.HashPassword(PassWordS))
                         select d).FirstOrDefault();

            if (check != null)
            {
                return(check.UserId);
            }
            else
            {
                return(0);
            }
        }
Пример #20
0
        public bool Login(string Email, string Password)
        {
            var FFieldUser = (from u in db.Users
                              where u.email.Equals(Email) &&
                              u.active.Equals(1) &&
                              u.password.Equals(Secrecy.HashPassword(Password)
                                                )
                              select u).FirstOrDefault();

            if (FFieldUser != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #21
0
        //allowing an already registered to gain access to the website
        public bool Login(string Email, string Password)
        {
            //checking whether password entered by user matches exsting one in the database
            var user = (from u in db.UserTables
                        where u.User_Email.Equals(Email) &&

                        u.Password.Equals(Secrecy.HashPassword(Password)
                                          )
                        select u).FirstOrDefault();

            if (user != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #22
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUsername.Value;
            string password = txtPassword.Value;
            int    userID;
            bool   a, b;
            bool   canLogin;

            bl.LoginEmployer(userName, Secrecy.HashPassword(password), out userID, out a, out canLogin, out b);
            if (canLogin)
            {
                Session.Add("UserID", userID);
                Session.Add("UserType", "Employer");
                Response.Redirect("Home.aspx");
            }
            else
            {
                bl.LoginJobSeeker(userName, Secrecy.HashPassword(password), out userID, out a, out canLogin, out b);
                if (canLogin)
                {
                    Session.Add("UserID", userID);
                    Session.Add("UserType", "JobSeeker");
                    Response.Redirect("Home.aspx");
                }
                else
                {
                    bl.LoginAdmin(userName, password, out userID, out a, out canLogin, out b);
                    if (canLogin)
                    {
                        Session.Add("UserID", userID);
                        Session.Add("UserType", "Admin");
                        Response.Redirect("Home.aspx");
                    }
                    else
                    {
                        lblErr.Text    = "Username/password incorrect";
                        lblErr.Visible = true;
                        return;
                    }
                }
            }
        }
Пример #23
0
        //Getting existing user from table
        public User GetUser(string Email, string Password)
        {
            var Ruser = (from u in db.UserTables
                         where u.User_Email.Equals(Email) &&
                         u.Password.Equals(Secrecy.HashPassword(Password))
                         select u).FirstOrDefault();

            User user = new User
            {
                ID      = Ruser.ID,
                Name    = Ruser.User_Name,
                surname = Ruser.User_Surname,
                email   = Ruser.User_Email,
                pass    = Ruser.Password,
                active  = Convert.ToInt32(Ruser.Active),
                type    = Ruser.UserType
            };

            return(user);
        }
        public void registerManagerJason(string manager)
        {
            var     jsonSerializer = new JavaScriptSerializer();
            Manager managerObject  = jsonSerializer.Deserialize <Manager>(manager);

            Manager managerToInsert = new Manager()
            {
                AuthenticationLevel = managerObject.AuthenticationLevel,
                ContactNumber       = managerObject.ContactNumber,
                Email          = managerObject.Email,
                Gender         = managerObject.Gender,
                ID             = managerObject.ID,
                Name           = managerObject.Name,
                Password       = Secrecy.HashPassword(managerObject.Password),
                EmployeeNumber = managerObject.EmployeeNumber,
                Surname        = managerObject.Surname,
                Title          = managerObject.Title
            };

            RegisterManager(managerToInsert);
        }
        public void RegisterClientJason(string client)
        {
            var    jsonSerializer = new JavaScriptSerializer();
            Client clientObject   = jsonSerializer.Deserialize <Client>(client);

            Client clientToInsert = new Client()
            {
                AuthenticationLevel = clientObject.AuthenticationLevel,
                ContactNumber       = clientObject.ContactNumber,
                Email       = clientObject.Email,
                FundingType = clientObject.FundingType,
                Gender      = clientObject.Gender,
                ID          = clientObject.ID,
                Title       = clientObject.Title,
                Name        = clientObject.Name,
                Password    = Secrecy.HashPassword(clientObject.Password),
                Surname     = clientObject.Surname,
            };

            RegisterClient(clientToInsert);
        }
        public string changePassword(string id, string oldPassword, string newPassword)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    var query = (from acc in db.HOTEL_MANAGERs where acc.MANAGER_ID.Equals(Convert.ToInt32(id)) select acc);
                    if (query.Count() == 1)
                    {
                        HOTEL_MANAGER student = query.Single();

                        string oldHashed    = Secrecy.HashPassword(oldPassword);
                        string passwordInDB = student.PASSWORD;

                        if (oldHashed == passwordInDB)
                        {
                            student.PASSWORD = Secrecy.HashPassword(newPassword);
                            db.SubmitChanges();

                            return("Password Changed");
                        }
                        else
                        {
                            return("Incorrect old password");
                        }
                    }
                    else
                    {
                        return("Failed to change password");
                    }
                }
            }



            catch (Exception)
            {
                return("Failed to change password");
            }
        }
Пример #27
0
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["token"] != null)
            {
                if (Request.QueryString["email"] != null)
                {
                    string email     = Request.QueryString["email"];
                    string decrypted = Server.HtmlDecode(Request.QueryString["token"].ToString());

                    if (txtConfirmNewPassword.Text.Length < 2)
                    {
                        lblSuccess.Text      = "";
                        lblErrorMessage.Text = "Password is too short";
                    }

                    if (txtConfirmNewPassword.Text == txtNewPassword.Text)
                    {
                        AccountConnection connection = new AccountConnection();

                        //Confirm that they have actually sent a link
                        if (connection.correctPasswordReset(email, decrypted))
                        {
                            //Change the password
                            string userType = connection.GetUserType(email);

                            if (userType == "COMPANY")
                            {
                                if (connection.resetPasswordCompany(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }
                            else if (userType == "SHOP")
                            {
                                if (connection.resetPasswordShopOwner(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }

                            else if (userType == "SOCIETY")
                            {
                                if (connection.resetPasswordSociety(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }
                            else if (userType == "STUDENT")
                            {
                                if (connection.resetPasswordStudent(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }

                            else if (userType == "PROPERTY")
                            {
                                if (connection.resetPasswordManagers(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }

                            else if (userType == "EVENTPOSTER")
                            {
                                if (connection.resetPasswordEventPoster(email, Secrecy.HashPassword(txtConfirmNewPassword.Text)))
                                {
                                    lblErrorMessage.Text = "";
                                    lblSuccess.Text      = "New password recorded successfully";
                                    connection.deletePasswordResetLink(email);
                                    Response.Redirect("tempLogin.aspx?page=passwordReset");//Redrect the user
                                }
                                else
                                {
                                    lblErrorMessage.Text = "Password Could not be recorded";
                                    lblSuccess.Text      = "";
                                }
                            }
                            else
                            {
                                lblErrorMessage.Text = "User Type does not exist";
                                lblSuccess.Text      = "";
                            }
                        }
                        else
                        {
                            lblErrorMessage.Text = "Password reset link already used, please reset your pass word again";
                            lblSuccess.Text      = "";
                        }
                    }
                    else
                    {
                        lblErrorMessage.Text = "Passwords don't match";
                        lblSuccess.Text      = "";
                    }
                }
                else
                {
                    lblErrorMessage.Text = "Please use the password reset link sent to your email";
                    lblSuccess.Text      = "";
                }
            }
            else
            {
                lblErrorMessage.Text = "Invalid Password Reset Link";
                lblSuccess.Text      = "";
            }
        }
Пример #28
0
        public BaseUser Login(string email, string password)
        {
            CLIENT        linqClient  = null;
            HOTEL_MANAGER linqManager = null;
            HOTEL_OWNER   linqOwner   = null;

            using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
            {
                try
                {
                    //Search queries
                    var query           = (from uClient in db.CLIENTs where uClient.EMAIL.Equals(email) && uClient.PASSWORD.Equals(Secrecy.HashPassword(password)) select uClient);
                    int linqClientCount = query.Count();
                    if (linqClientCount == 1)
                    {
                        linqClient = query.Single();
                        BaseUser client = new BaseUser();
                        client.ID                  = linqClient.CLIENT_ID;
                        client.Title               = linqClient.TITLE;
                        client.Surname             = linqClient.SURNAME;
                        client.Name                = linqClient.FULL_NAMES;
                        client.Gender              = linqClient.GENDER;
                        client.Email               = linqClient.EMAIL;
                        client.ContactNumber       = linqClient.CONTACT_NUM;
                        client.AuthenticationLevel = linqClient.AUTHENTICATION_LEVEL;

                        return(client);
                    }
                    else if (linqClientCount == 0)
                    {
                        var query2           = (from uOff in db.HOTEL_MANAGERs where uOff.EMAIL.Equals(email) && uOff.PASSWORD.Equals(Secrecy.HashPassword(password)) select uOff);
                        int linqOfficerCount = query2.Count();
                        if (linqOfficerCount == 1)
                        {
                            linqManager = query2.Single();
                            if (linqManager.AUTHENTICATION_LEVEL == "M")
                            {
                                BaseUser manager = new BaseUser();
                                manager.Title               = linqManager.TITLE;
                                manager.Surname             = linqManager.SURNAME;
                                manager.Name                = linqManager.FULL_NAMES;
                                manager.Gender              = linqManager.GENDER;
                                manager.Email               = linqManager.EMAIL;
                                manager.ContactNumber       = linqManager.CONTACT_NUM;
                                manager.AuthenticationLevel = linqManager.AUTHENTICATION_LEVEL;
                                manager.ID = linqManager.MANAGER_ID;

                                return(manager);
                            }
                            else
                            {
                                return(null);
                            }
                        }
                        else
                        {
                            var query3         = (from uOwn in db.HOTEL_OWNERs where uOwn.EMAIL.Equals(email) && uOwn.PASSWORD.Equals(Secrecy.HashPassword(password)) select uOwn);
                            int linqOwnerCount = query3.Count();
                            if (linqOwnerCount == 1)
                            {
                                linqOwner = query3.Single();
                                BaseUser owner = new BaseUser();

                                owner.Title               = linqOwner.TITLE;
                                owner.Surname             = linqOwner.SURNAME;
                                owner.Name                = linqOwner.FULL_NAMES;
                                owner.Gender              = linqOwner.GENDER;
                                owner.Email               = linqOwner.EMAIL;
                                owner.ContactNumber       = linqOwner.CONTACT_NUM;
                                owner.AuthenticationLevel = linqOwner.AUTHENTICATION_LEVEL;
                                owner.ID = linqOwner.OWNER_ID;

                                return(owner);
                            }
                            else if (linqOwnerCount == 0)
                            {
                                return(null);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    return(null); //Find another way
                }
                return(null);     //Find another way
            }
        }
Пример #29
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //if (txtEmail.Text != "*****@*****.**")
            //{
            //    lblErrorMessage.Text = "";
            //    lblSuccess.Text = "Website under maintenance mode";
            //    return;
            //}

            AccountConnection connection = new AccountConnection();

            //Check if the user exists in the unconifirmed accounts
            if (connection.unconfirmedAccount(txtEmail.Text))
            {
                lblErrorMessage.Text = "Please check your Inbox folder for confirmation email";
                lblSuccess.Text      = "";
            }
            else
            {
                Student s = connection.loginStudent(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                if (s != null)
                {
                    Session["STUDENT"] = s;

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Student"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Student/students-profile.aspx");
                }
                else if (connection.correctShopOwner(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["SHOPOWNER"] = connection.loginShopOwner(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Shop"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Shop/Home.aspx");
                }
                else if (connection.correctEventPoster(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["EVENTPOSTER"] = connection.loginEventPoster(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("EventPoster"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/EventPoster/Home.aspx");
                }
                else if (connection.correctSociety(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["SOCIETY"] = connection.loginSociety(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Society"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Society/Home.aspx");
                }
                else if (connection.correctCompany(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["COMPANY"] = connection.loginCompany(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Company"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Company/Home.aspx");
                }
                else if (connection.correctPropertyManager(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["PROPERTYMANAGER"] = connection.loginPropertyManager(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Accommodation"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Accommodation/landlord-my-rooms.aspx");
                }
                else if (txtPassword.Text == "2g@63po" && txtEmail.Text == "*****@*****.**")
                {
                    //connection.adminAccess(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text))
                    Session["ADMIN"] = "*****@*****.**";
                    Response.Redirect("~/Web/Users/Admin/ListOfUsers.aspx");
                }
                else
                {
                    lblErrorMessage.Text = "Email or Password is incorrect";
                    lblSuccess.Text      = "";
                }
            }
        }
Пример #30
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            //getting the values from the textboxes
            string firstName               = txtFirstName.Text;
            string lastName                = txtLastName.Text;
            string emailAddress            = txtEmail.Text;
            string password                = txtPassword.Text;
            string cellphoneNumbers        = txtCellphone.Text;
            string altanativeContactNumber = txtAltContactNum.Text;
            string residentialAddress      = txtResAddress.Text;

            int userLevel = System.Convert.ToInt32(drpUsertype.SelectedValue);

            //byte[] fileBytes = ProfileImageUpload.FileBytes;
            //System.Drawing.Image profileImage = getImageFromByteArray(fileBytes);

            //string profImage_string = ImageToBase64String(profileImage);

            if (password.Length < 6) //ensure the password strength is atleast 6 characters
            {
                lblError.Text    = "Make sure your password is 6 characters or more";
                lblError.Visible = true;
                return;
            }

            if (password == txtConfirmPassword.Text)
            {
                if (emailAddress == " ")
                {
                    lblError.Text    = "Make sure your e-mail address is not empty";
                    lblError.Visible = true;
                    return;
                }
                else
                {
                    if (userLevel.Equals(1))
                    {
                        if (image.Equals("none"))
                        {
                            lblError.Text    = "Please ensure that you have selected a profile image";
                            lblError.Visible = true;
                            return;
                        }
                        cl.RegisterEmployer(firstName, lastName, emailAddress, Secrecy.HashPassword(password), cellphoneNumbers, altanativeContactNumber, residentialAddress, image);
                        Session["Image"] = null; // set session to null
                        Response.Redirect("LoginPage.aspx");
                    }
                    else if (userLevel.Equals(2))
                    {
                        if (image.Equals("none"))
                        {
                            lblError.Text    = "Please ensure that you have selected a profile image";
                            lblError.Visible = true;
                            return;
                        }
                        cl.RegisterJobSeeker(firstName, lastName, emailAddress, Secrecy.HashPassword(password), cellphoneNumbers, altanativeContactNumber, residentialAddress, image);
                        Session["Image"] = null; // set session to null
                        Response.Redirect("LoginPage.aspx");
                    }
                    else
                    {
                        lblError.Text    = "Make sure you select whether to register as an employer or a job seeker";
                        lblError.Visible = true;
                        return;
                    }
                }
            }
            else
            {
                lblError.Text    = "Make sure your password and confirm password match";
                lblError.Visible = true;
                return;
            }
        }