Exemplo n.º 1
0
        protected void LoginUser(string userEmail, string userPass)
        {
            //make new encrpytion object
            pEncryption pEncrypt = new pEncryption();
            //set UserName to equal txtUsername text
            userEmail = txtUserEmail.Value;
            //encrypt password
            String ecryptPassword = pEncrypt.EncryptQueryString(userPass);
            //make new user object
            User usr = new User();
            //calls Login property of user that uses storage procedure to check login
            usr.Login(userEmail, ecryptPassword);

            if (!usr.IsNew)
            {
                //make a string called usrNme, set its value to usr.UserName
                String usrNme = usr.UserName;
                //make a new guid called usrID, set its value to usr.Id
                Guid usrID = new Guid(usr.Id.ToString());
                showLoggedIn(usrNme, usrID);
            }
            else
            {
                //if not successful, transfer user to registration page
                Session["LoggedIn"] = 0;
                Response.Redirect("Registration.aspx");
            }
        }
Exemplo n.º 2
0
        void btnLogin_Click(object sender, EventArgs e)
        {
            //make new encrpytion object
            pEncryption pEncrypt = new pEncryption();
            //set UserName to equal txtUsername text
            String UserName = this.txtUsername.Value;
            //encrypt password
            String ecryptPassword = pEncrypt.EncryptQueryString(this.txtPassword.Value);
            //make new user object
            User usr = new User();
            //calls Login property of user that uses storage procedure to check login
            usr.Login(UserName, ecryptPassword);

            if (!usr.IsNew)
            {
                //store username in string
                String usrNme = usr.UserName;
                //store UserID in guid
                Guid usrID = new Guid(usr.Id.ToString());
                //make a label called mpLabel, find the label called lblLogin in Master page
                HyperLink mpHyperLink = (HyperLink)Master.FindControl("hlLogin");

                if (mpHyperLink != null)
                {
                    //if mpLabel is not null then the mpLabel.Text equals login name
                    mpHyperLink.Text = usrNme;
                    //save user name to session
                    Session["UserName"] = mpHyperLink.Text;
                    //save user id to session
                    Session["UserID"] = usrID;
                    Session["LoggedIn"] = 1;

                    //transfer to the default page upon success
                    Server.Transfer("Default.aspx", true);
                }
            }
            else
            {
                //if not successful, transfer user to registration page
                Session["LoggedIn"] = 0;
                Response.Redirect("Registration.aspx");
            }
        }
Exemplo n.º 3
0
        void btnRegister_Click(object sender, EventArgs e)
        {
            //make new encrpytion object
            pEncryption pEncrypt = new pEncryption();
            //make new user object
            User user = new User();
            //set user properties to input values
            user.UserName = this.txtUserName.Value;
            //Encrypt password before saving (this enhances security)
            user.Password = pEncrypt.EncryptQueryString(this.txtPassword.Value);
            user.Email = this.txtEmail.Value;
            user.SecurityQuestion = this.txtSecurityQuestion.Value;
            //Decided to encrypt the answer for extra security
            user.SecurityAnswer = pEncrypt.EncryptQueryString(this.txtSecurityAnswer.Value);
            user.UserBIO = string.Empty;

            if (user.IsSavable() == true)
            {
                //if user is savable, then save and reroute to default
                user = user.Save();
                Server.Transfer("Default.aspx", true);
            }
        }