protected void btn_reg_Click(object sender, EventArgs e)
        {
            if (lbl_checkemail.Text == HardCodedValues.BuddaResource.EmailIdAvailable)
            {
                //Check whether the Captcha text is correct or not
                if (this.txt_captcha.Text == this.Session["CaptchaImageText"].ToString())
                {
                    string uname        = txt_username.Text;
                    string emailid      = txt_emailid.Text;
                    string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(txt_password.Text);

                    bool verfyDomain = verifyDomain(emailid);
                    bool chkEmail    = sendEmail(emailid);

                    if (verfyDomain && chkEmail)
                    {
                        BusinessEntitiesBS.UserEntities.userobj userObj = new BusinessEntitiesBS.UserEntities.userobj();

                        userObj.uname   = uname;
                        userObj.emailid = emailid;
                        userObj.pwd     = encryptedpwd;
                        try
                        {
                            IUser userInsert = new UserItems();

                            //insert new user details in database with given values
                            userInsert.insertUser(userObj);

                            dt = userInsert.checklogin(emailid, encryptedpwd);
                            this.Session["currentuser"] = dt;

                            //lbl_register.Text = "Registration Successfull";
                            Response.Redirect("~/USER/ProfilePage.aspx");
                        }
                        catch (Exception exp)
                        {
                            lbl_register.Text = HardCodedValues.BuddaResource.CatchBlockError + exp.Message;
                        }
                    }
                    else
                    {
                        lbl_register.Text = "Registration Incomplete! Invalid email id or domain. Please provide valid email for regitration.";
                    }
                }
                else
                {
                    txt_captcha.Text = "";
                    lbl_captcha.Text = HardCodedValues.BuddaResource.CaptchaError;
                    // Create a random Captcha and store it in the Session object.
                    this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(7);
                    txt_captcha.Focus();
                }
            }
            else
            {
                txt_emailid.Focus();
            }
        }
Пример #2
0
        public bool RegisterUser(string emailid, string password)
        {
            try
            {
                IUser checkuser = new UserItems();

                //returns the table if given emailid exists
                dt = checkuser.checkavailability(emailid);
                if (dt == null)
                {
                    string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(password);
                    BusinessEntitiesBS.UserEntities.userobj userObj = new BusinessEntitiesBS.UserEntities.userobj();

                    userObj.uname   = "";
                    userObj.emailid = emailid;
                    userObj.pwd     = encryptedpwd;
                    try
                    {
                        IUser userInsert = new UserItems();

                        //insert new user details in database with given values
                        userInsert.insertUser(userObj);

                        DataTable dt2 = userInsert.checklogin(emailid, encryptedpwd);

                        this.Session["currentuser"] = dt2;

                        return(true);
                    }
                    catch (Exception exp)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }