Beispiel #1
0
        protected void btn_ChangeSvvMailId_Click(object sender, EventArgs e)
        {
            string error;
            string current_SvvMailId = HashGenerator.URLDecrypt(Request.QueryString["svvmailid"]);
            string password_hash     = HashGenerator.getHash(tb_newSvvMailId.Text, tb_newPassword.Text);

            if (ValidEmailId)
            {
                if (DataAccessLayer.isStudentEmailIdChangedSuccessfully(current_SvvMailId, tb_newSvvMailId.Text, password_hash, out error))
                {
                    if (error == null)
                    {
                        SendMailManager mail        = new SendMailManager();
                        string          messageType = "verification";
                        if (mail.sendMail(tb_newSvvMailId.Text, messageType, out error))
                        {
                            if (error == null)
                            {
                                string str_enc_email   = HashGenerator.URLEncrypt(tb_newSvvMailId.Text);
                                string str_enc_attempt = HashGenerator.URLEncrypt("1");
                                Response.Redirect("verifyInfo.aspx?svvmailid=" + str_enc_email + "&attempt=" + str_enc_attempt);
                            }
                            else
                            {
                                lbl_changeSvvEmailId_Status.Text = error;
                            }
                        }
                        else
                        {
                            lbl_changeSvvEmailId_Status.Text = "Cannot Send the Verification Mail";
                        }
                    }
                    else
                    {
                        lbl_changeSvvEmailId_Status.Text = error;
                    }
                }
                else
                {
                    lbl_changeSvvEmailId_Status.Text = "Some Error Occured";
                }
            }
            else
            {
                lbl_changeSvvEmailId_Status.Text = "Svv ID Already Exist";
            }
        }
        protected void btn_ChangeSvvMailId_Click(object sender, EventArgs e)
        {
            string error;
            string current_SvvMailId = HashGenerator.URLDecrypt(Request.QueryString["svvmailid"]);
            string password_hash = HashGenerator.getHash(tb_newSvvMailId.Text, tb_newPassword.Text);
            if (ValidEmailId)
            {
                if (DataAccessLayer.isStudentEmailIdChangedSuccessfully(current_SvvMailId, tb_newSvvMailId.Text, password_hash, out error))
                {
                    if (error == null)
                    {
                        SendMailManager mail = new SendMailManager();
                        string messageType = "verification";
                        if (mail.sendMail(tb_newSvvMailId.Text, messageType, out error))
                        {
                            if (error == null)
                            {
                                string str_enc_email = HashGenerator.URLEncrypt(tb_newSvvMailId.Text);
                                string str_enc_attempt = HashGenerator.URLEncrypt("1");
                                Response.Redirect("verifyInfo.aspx?svvmailid=" + str_enc_email + "&attempt=" + str_enc_attempt);

                            }
                            else {
                                lbl_changeSvvEmailId_Status.Text = error;
                            }
                        }
                        else
                        {
                            lbl_changeSvvEmailId_Status.Text = "Cannot Send the Verification Mail";
                        }
                    }
                    else
                    {
                        lbl_changeSvvEmailId_Status.Text = error;
                    }
                }
                else
                {
                    lbl_changeSvvEmailId_Status.Text = "Some Error Occured";
                }
            }
            else
            {
                lbl_changeSvvEmailId_Status.Text = "Svv ID Already Exist";
            }
        }
Beispiel #3
0
        protected void btnResendMail_Click(object sender, EventArgs e)
        {
            string dec_svvmail_id = HashGenerator.URLDecrypt(Request.QueryString["svvmailid"]);
            string error, verified;

            if (DataAccessLayer.isStdEmailVerificationPending(dec_svvmail_id, out verified, out error))
            {
                if (error == null && verified != null)
                {
                    if (verified != "1")
                    {
                        string          msgType    = "verification";//dont change this. it is for slecting the type of email msg body.
                        SendMailManager resendMail = new SendMailManager();
                        if (resendMail.sendMail(dec_svvmail_id, msgType, out error))
                        {
                            if (error == null)
                            {
                                Label1.Text = "Verification Email has been Send to your Registered Email ID :" + dec_svvmail_id + "<br/>Please Check Your Svv Mail Inbox and Click On <u>Activate Your Account</u> Link";
                            }
                            else
                            {
                                Label1.Text = "here 2" + error;
                            }
                        }
                        else
                        {
                            Label1.Text = "Email Not Sent";
                        }
                    }
                    else
                    {
                        Label1.Text = "This Email Id is Already Registered...";
                    }
                }
                else
                {
                    Label1.Text = "here" + error;
                }
            }
            else
            {
                Label1.Text = "Your Email ID is Already Verified...";
            }
        }
        protected void btnResendMail_Click(object sender, EventArgs e)
        {
            string dec_svvmail_id = HashGenerator.URLDecrypt(Request.QueryString["svvmailid"]);
            string error,verified;
            if (DataAccessLayer.isStdEmailVerificationPending(dec_svvmail_id,out verified, out error))
            {
                if (error == null && verified != null)
                {
                    if (verified != "1")
                    {
                        string msgType = "verification";//dont change this. it is for slecting the type of email msg body.
                        SendMailManager resendMail = new SendMailManager();
                        if (resendMail.sendMail(dec_svvmail_id, msgType, out error))
                        {
                            if (error == null)
                            {
                                Label1.Text = "Verification Email has been Send to your Registered Email ID :" + dec_svvmail_id+"<br/>Please Check Your Svv Mail Inbox and Click On <u>Activate Your Account</u> Link";
                            }
                            else {
                                Label1.Text ="here 2" + error;
                            }
                        }
                        else {
                            Label1.Text = "Email Not Sent";
                        }
                    }
                    else {
                        Label1.Text = "This Email Id is Already Registered...";
                    }
                }
                else {
                    Label1.Text = "here" +error;
                }
            }
            else {
                Label1.Text = "Your Email ID is Already Verified...";
            }

        }
        protected void btn_forgotPass_Click(object sender, EventArgs e)
        {
            string          email = tb_forgotEmailID.Text;
            string          mailError;
            string          msgType        = "forgotPass";//dont change this. it is for slecting the type of email msg body.
            SendMailManager forgotPassMail = new SendMailManager();

            if (forgotPassMail.sendMail(email, msgType, out mailError))
            {
                if (mailError == null)
                {
                    btn_forgotPass.Visible        = false;
                    lbl_forgotPassStatus.CssClass = "mdl-color-text--primary";
                    lbl_forgotPassStatus.Text     = "Password Reset Link Was send To your SVV mail ID...";
                    tb_forgotEmailID.Text         = string.Empty;
                }
                else
                {
                    btn_forgotPass.Visible    = true;
                    lbl_forgotPassStatus.Text = mailError;
                }
            }
            else
            {
                btn_forgotPass.Visible    = true;
                lbl_forgotPassStatus.Text = "Cannot Send The email";
            }


            //forgotPassEmail_tb_regex_validator.Dispose();
            //RequiredFieldValidator1.Dispose();
            //btn_forgotPass.Visible = false;
            //string error_isEmailIDExist;
            //string student_id;
            //string sp_name = "sp_isStdEmailIDExist";// for wich store procedure has to be called, cause only one method is there for finding universal svv mail id
            //if (DataAccessLayer.isEmailIDExist_getItsID(tb_forgotEmailID.Text,sp_name, out error_isEmailIDExist, out student_id))
            //{
            //    //lbl_forgotPassStatus.Text = tb_forgotEmailID.Text;
            //    if (error_isEmailIDExist == null && student_id !=null)
            //    {
            //        string uid = HashGenerator.getUniqueID();
            //        string error_isUniqueCodeUpdated;
            //        //lbl_forgotPassStatus.Text = "<br/>" + uid.Length.ToString();
            //        if (DataAccessLayer.isUniqueCodeUpdated(tb_forgotEmailID.Text, uid, out error_isUniqueCodeUpdated))
            //        {
            //            if (error_isUniqueCodeUpdated == null)
            //            {
            //                try
            //                {
            //                    string url = "http://hardikt-001-site1.ctempurl.com/resetPass.aspx?token=" + uid+"&id="+student_id;
            //                    //lbl_forgotPassStatus.Text = url;
            //                    MailMessage msg = new MailMessage();
            //                    msg.From = new MailAddress("*****@*****.**");

            //                    msg.To.Add(tb_forgotEmailID.Text.Trim());
            //                    msg.Subject = "Password Recovery Request";
            //                    msg.Body = "Someone has requested that the password be reset for your account " + tb_forgotEmailID.Text + " on <a href='hardikt-001-site1.ctempurl.com'>skstpc.edu</a>.<br/><br/>If you made this request, click this below link to change your password.<br/><br/>url: " + url + "<br/><br/>If you did not make this request, click here to cancel the request.";
            //                    msg.IsBodyHtml = true;

            //                    NetworkCredential mailAuthenticaion = new NetworkCredential("*****@*****.**", "*****@*****.**");
            //                    SmtpClient mailsmtp = new SmtpClient("smtp.gmail.com", 587);
            //                    mailsmtp.EnableSsl = true;
            //                    mailsmtp.UseDefaultCredentials = false;
            //                    mailsmtp.Credentials = mailAuthenticaion;
            //                    mailsmtp.Send(msg);
            //                    btn_forgotPass.Visible = false;
            //                    lbl_forgotPassStatus.CssClass = "mdl-color-text--primary";
            //                    lbl_forgotPassStatus.Text = "Password Reset Link Was send To your SVV mail ID...";
            //                    tb_forgotEmailID.Text = string.Empty;
            //                }
            //                catch (Exception ex)
            //                {
            //                    btn_forgotPass.Visible = true;
            //                    lbl_forgotPassStatus.Text = ex.Message;
            //                }
            //            }
            //            else {
            //                btn_forgotPass.Visible = true;
            //                lbl_forgotPassStatus.Text = error_isUniqueCodeUpdated;
            //            }
            //        }
            //        else {
            //            lbl_forgotPassStatus.Text = "Could not create or Update UID/Token";
            //        }
            //    }
            //    else
            //    {
            //        btn_forgotPass.Visible = true;
            //        lbl_forgotPassStatus.Text = error_isEmailIDExist + "student id";
            //    }
            //}
            //else
            //{
            //    btn_forgotPass.Visible = true;
            //    lbl_forgotPassStatus.Text = "No Such User Found";
            ////    string uid = HashGenerator.getUniqueID();
            ////    lbl_forgotPassStatus.Text = uid;
            //}
            //lbl_forgotPassStatus.Text = tb_forgotEmailID.Text;
        }
        protected void btnStudentReg_Click(object sender, EventArgs e)
        {
            if (isValidEmail == true && signup_emailid.Text != null)
            {
                //collecting data from form
                string fname  = signup_fname.Text;
                string lname  = signup_lname.Text;
                string stream = listClass.SelectedItem.Value;
                string gender = Request.Form["options"];
                string email  = signup_emailid.Text.Trim();
                string pass   = signup_password.Text;
                //End collecting data

                string hashval = HashGenerator.getHash(email, pass);                                                 //generating sha1
                string error;
                if (DataAccessLayer.isStudentRegSuccessful(fname, lname, stream, gender, email, hashval, out error)) //passing to method for updating
                {
                    if (error != null)
                    {
                        Label1.Text = error;
                    }
                    else
                    {
                        isValidEmail = false;
                        string          mailerror;
                        SendMailManager regmail = new SendMailManager();
                        string          msgType = "verification";//dont change this. it is for slecting the type of email msg body
                        if (regmail.sendMail(signup_emailid.Text.Trim(), msgType, out mailerror))
                        {
                            if (mailerror == null)
                            {
                                // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "customScript", "<script type='text/javascript'> $('#spinner2').hide(); alert('You Succesfully Registered...!\\n Click Ok to Login');window.location.replace('studentLogin.aspx');</script>", false);
                                //string enc_signup_emailID = HttpUtility.UrlEncode(email);
                                string str_enc_email   = HashGenerator.URLEncrypt(email);
                                string str_enc_attempt = HashGenerator.URLEncrypt("1");
                                Response.Redirect("verifyInfo.aspx?svvmailid=" + str_enc_email + "&attempt=" + str_enc_attempt);
                            }
                            else
                            {
                                Label1.Text = mailerror;
                            }
                        }
                        else     //if mail cannot be send for some reasons then that student should be deleted automatically, so that he/she can register again, otherwise if the mail sending fail then he cannot login and if he thought to do the registration again he/she cannot do that because we are checking that the email id is exists or on on registration..
                        {
                            string deleteerror;
                            if (DataAccessLayer.isStudentDeleted(signup_emailid.Text, out deleteerror))
                            {
                                if (deleteerror == null)
                                {
                                    Label1.Text = "Cannot Create The user Because Mail Not send and user Deleted";
                                }
                                else
                                {
                                    Label1.Text = "Cannot Create User Because Mail Not send and Also Cannot Delete user it because of error :" + deleteerror;
                                }
                            }
                            else
                            {
                                Label1.Text = "Cannot Create User Because Mail Not send and Also Cannot Delete user";
                            }
                        }
                    }
                }
                else
                {
                    Label1.Text = "Some Error Occured. Make Sure You had Filled all the Fields";
                }
            }
            //Label1.Text = fname +"<br>" +lname + "<br>" + stream + "<br>" + gender + "<br>" + email + "<br>" + pass; //for testing
            else
            {
                signup_fname.Text = string.Empty;
                signup_lname.Text = string.Empty;
                listClass.ClearSelection();
                Request.Form["options"] = string.Empty;
                signup_emailid.Text     = string.Empty;
                signup_password.Text    = string.Empty;
                UpdatePanel1.Update();
                UpdatePanel2.Update();
                Label1.Text = "This Svv Mail ID is Already Exist <br/> If you Forgot Your Password Click <a href='forgotpass.aspx'>Here</a> to Recover Your Password'";
            }
        }
        protected void btn_forgotPass_Click(object sender, EventArgs e)
        {
            string email = tb_forgotEmailID.Text;
            string mailError;
            string msgType = "forgotPass";//dont change this. it is for slecting the type of email msg body.
            SendMailManager forgotPassMail = new SendMailManager();
            if (forgotPassMail.sendMail(email, msgType, out mailError))
            {
                if (mailError == null)
                {
                    btn_forgotPass.Visible = false;
                    lbl_forgotPassStatus.CssClass = "mdl-color-text--primary";
                    lbl_forgotPassStatus.Text = "Password Reset Link Was send To your SVV mail ID...";
                    tb_forgotEmailID.Text = string.Empty;
                }
                else
                {
                    btn_forgotPass.Visible = true;
                    lbl_forgotPassStatus.Text = mailError;
                }
            }
            else {
                btn_forgotPass.Visible = true;
                lbl_forgotPassStatus.Text = "Cannot Send The email";
            }


            //forgotPassEmail_tb_regex_validator.Dispose();
            //RequiredFieldValidator1.Dispose();
            //btn_forgotPass.Visible = false;
            //string error_isEmailIDExist;
            //string student_id;
            //string sp_name = "sp_isStdEmailIDExist";// for wich store procedure has to be called, cause only one method is there for finding universal svv mail id
            //if (DataAccessLayer.isEmailIDExist_getItsID(tb_forgotEmailID.Text,sp_name, out error_isEmailIDExist, out student_id))
            //{
            //    //lbl_forgotPassStatus.Text = tb_forgotEmailID.Text;
            //    if (error_isEmailIDExist == null && student_id !=null)
            //    {
            //        string uid = HashGenerator.getUniqueID();
            //        string error_isUniqueCodeUpdated;
            //        //lbl_forgotPassStatus.Text = "<br/>" + uid.Length.ToString();
            //        if (DataAccessLayer.isUniqueCodeUpdated(tb_forgotEmailID.Text, uid, out error_isUniqueCodeUpdated))
            //        {
            //            if (error_isUniqueCodeUpdated == null)
            //            {
            //                try
            //                {
            //                    string url = "http://hardikt-001-site1.ctempurl.com/resetPass.aspx?token=" + uid+"&id="+student_id;
            //                    //lbl_forgotPassStatus.Text = url;
            //                    MailMessage msg = new MailMessage();
            //                    msg.From = new MailAddress("*****@*****.**");

            //                    msg.To.Add(tb_forgotEmailID.Text.Trim());
            //                    msg.Subject = "Password Recovery Request";
            //                    msg.Body = "Someone has requested that the password be reset for your account " + tb_forgotEmailID.Text + " on <a href='hardikt-001-site1.ctempurl.com'>skstpc.edu</a>.<br/><br/>If you made this request, click this below link to change your password.<br/><br/>url: " + url + "<br/><br/>If you did not make this request, click here to cancel the request.";
            //                    msg.IsBodyHtml = true;

            //                    NetworkCredential mailAuthenticaion = new NetworkCredential("*****@*****.**", "*****@*****.**");
            //                    SmtpClient mailsmtp = new SmtpClient("smtp.gmail.com", 587);
            //                    mailsmtp.EnableSsl = true;
            //                    mailsmtp.UseDefaultCredentials = false;
            //                    mailsmtp.Credentials = mailAuthenticaion;
            //                    mailsmtp.Send(msg);
            //                    btn_forgotPass.Visible = false;
            //                    lbl_forgotPassStatus.CssClass = "mdl-color-text--primary";
            //                    lbl_forgotPassStatus.Text = "Password Reset Link Was send To your SVV mail ID...";
            //                    tb_forgotEmailID.Text = string.Empty;
            //                }
            //                catch (Exception ex)
            //                {
            //                    btn_forgotPass.Visible = true;
            //                    lbl_forgotPassStatus.Text = ex.Message;
            //                }
            //            }
            //            else {
            //                btn_forgotPass.Visible = true;
            //                lbl_forgotPassStatus.Text = error_isUniqueCodeUpdated;
            //            }
            //        }
            //        else {
            //            lbl_forgotPassStatus.Text = "Could not create or Update UID/Token";
            //        }
            //    }
            //    else
            //    {
            //        btn_forgotPass.Visible = true;
            //        lbl_forgotPassStatus.Text = error_isEmailIDExist + "student id";
            //    }
            //}
            //else
            //{
            //    btn_forgotPass.Visible = true;
            //    lbl_forgotPassStatus.Text = "No Such User Found";
            ////    string uid = HashGenerator.getUniqueID();
            ////    lbl_forgotPassStatus.Text = uid;
            //}
            //lbl_forgotPassStatus.Text = tb_forgotEmailID.Text;
            
        }
        protected void btnStudentReg_Click(object sender, EventArgs e)
        {
            if (isValidEmail == true && signup_emailid.Text != null)
            {
                //collecting data from form
                string fname = signup_fname.Text;
                string lname = signup_lname.Text;
                string stream = listClass.SelectedItem.Value;
                string gender = Request.Form["options"];
                string email = signup_emailid.Text.Trim();
                string pass = signup_password.Text;
                //End collecting data

                string hashval = HashGenerator.getHash(email, pass); //generating sha1
                string error;
                if (DataAccessLayer.isStudentRegSuccessful(fname, lname, stream, gender, email, hashval, out error))//passing to method for updating
                {
                    if (error != null)
                    {
                        Label1.Text = error;
                    }
                    else {
                        isValidEmail = false;
                        string mailerror;
                        SendMailManager regmail = new SendMailManager();
                        string msgType = "verification";//dont change this. it is for slecting the type of email msg body
                        if (regmail.sendMail(signup_emailid.Text.Trim(), msgType, out mailerror))
                        {
                            if (mailerror == null)
                            {
                                // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "customScript", "<script type='text/javascript'> $('#spinner2').hide(); alert('You Succesfully Registered...!\\n Click Ok to Login');window.location.replace('studentLogin.aspx');</script>", false);
                                //string enc_signup_emailID = HttpUtility.UrlEncode(email);
                                string str_enc_email = HashGenerator.URLEncrypt(email);
                                string str_enc_attempt = HashGenerator.URLEncrypt("1");
                                Response.Redirect("verifyInfo.aspx?svvmailid=" + str_enc_email+"&attempt="+str_enc_attempt);
                            }
                            else {
                                Label1.Text = mailerror;
                            }
                        }
                        else {   //if mail cannot be send for some reasons then that student should be deleted automatically, so that he/she can register again, otherwise if the mail sending fail then he cannot login and if he thought to do the registration again he/she cannot do that because we are checking that the email id is exists or on on registration..
                            string deleteerror;
                            if (DataAccessLayer.isStudentDeleted(signup_emailid.Text, out deleteerror))
                            {
                                if (deleteerror == null)
                                {
                                    Label1.Text = "Cannot Create The user Because Mail Not send and user Deleted";
                                }
                                else {
                                    Label1.Text = "Cannot Create User Because Mail Not send and Also Cannot Delete user it because of error :" + deleteerror;
                                }
                            }
                            else {
                                Label1.Text = "Cannot Create User Because Mail Not send and Also Cannot Delete user";
                            }
                        }
                    }
                }
                else
                {
                    Label1.Text = "Some Error Occured. Make Sure You had Filled all the Fields";
                }
            }
            //Label1.Text = fname +"<br>" +lname + "<br>" + stream + "<br>" + gender + "<br>" + email + "<br>" + pass; //for testing
            else {
                signup_fname.Text = string.Empty;
                signup_lname.Text = string.Empty;
                listClass.ClearSelection();
                Request.Form["options"] = string.Empty;
                signup_emailid.Text = string.Empty;
                signup_password.Text = string.Empty;
                UpdatePanel1.Update();
                UpdatePanel2.Update();
                Label1.Text = "This Svv Mail ID is Already Exist <br/> If you Forgot Your Password Click <a href='forgotpass.aspx'>Here</a> to Recover Your Password'";
            }
        }