protected void btnForgotPasword_Click(object sender, EventArgs e) { JaslokMailer objMailer = new JaslokMailer(); List <Parameters> lstParameters = new List <Parameters>(); MembershipUser objUser = Membership.GetUser(txtForgotPasswordUserName.Text.Trim()); string lsEmailStatus = string.Empty; if (objUser != null) { UserInfo objInfo = new UserInfo(); objInfo = UserController.GetUserByName(objUser.UserName); string lsmobileNumber = objInfo.Profile.GetPropertyValue("PhoneNumber"); string lsPassword; lsPassword = objUser.GetPassword(); //sendmail(objUser.Email, lsPassword); if (!string.IsNullOrEmpty(lsmobileNumber)) { CommonFn.SendSMS(lsmobileNumber.Replace("-", ""), "Your password is: " + lsPassword); } lstParameters.Add(new Parameters { ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text }); lstParameters.Add(new Parameters { ShortCodeName = "Password", ShortCodeValue = lsPassword }); lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, objInfo.Email, null); if (string.IsNullOrEmpty(lsEmailStatus)) { lblForgotPassError.Text = "Password has been sent to your email address."; lblForgotPassError.CssClass = "successText"; } else { lblForgotPassError.Text = "Problem in sending email"; lblForgotPassError.CssClass = "errorText"; } txtForgotPasswordUserName.Text = ""; //lblGeneratedPassword.Text = lsPassword; } else { //Response.Redirect("/"); lblForgotPassError.CssClass = "errorText"; lblForgotPassError.Text = "Username does not exist."; txtForgotPasswordUserName.Text = ""; } }
protected void lnkResendOTP_Click(object sender, EventArgs e) { int liUserId = 0; bool _IsExpired = OTPVerification(OTPCheck.Resend, out liUserId); if (liUserId > 0) { string lsOtp = Guid.NewGuid().ToString().ToUpper().Split('-')[0]; UserInfo oUser = new UserInfo(); oUser = UserController.GetUserById(0, liUserId); if (oUser.Membership.Approved) { lblOTPError.CssClass = "errorText"; lblOTPError.Text = "Mobile number is already verified."; divLoginForm.Attributes.Add("style", "display:none;"); divOTPVerification.Attributes.Add("style", "display:block;"); } else if (!_IsExpired) { lblOTPError.CssClass = "errorText"; lblOTPError.Text = "Your last verification code is not yet expire."; divLoginForm.Attributes.Add("style", "display:none;"); divOTPVerification.Attributes.Add("style", "display:block;"); } else { oUser.Profile.SetProfileProperty("OTP", lsOtp); UserController.UpdateUser(0, oUser); CommonFn.SendSMS(oUser.Profile.GetPropertyValue("PhoneNumber").Replace("-", string.Empty), "Your one time verification code is: " + lsOtp + ".This code is valid for next 10mins only."); lblOTPError.CssClass = "successText"; lblOTPError.Text = "OTP code successfully sent to mobile. Please enter OTP code and click on submit."; divLoginForm.Attributes.Add("style", "display:none;"); divOTPVerification.Attributes.Add("style", "display:block;"); } } else { lblOTPError.CssClass = "errorText"; lblOTPError.Text = "No user is registered with above mobile number"; divLoginForm.Attributes.Add("style", "display:none;"); divOTPVerification.Attributes.Add("style", "display:block;"); } }
protected void btnOTPVerification_Click(object sender, EventArgs e) { int UserID = -1; if (!OTPVerification(OTPCheck.Verification, out UserID)) { UserInfo objUserInfo = new UserInfo(); objUserInfo = UserController.GetUserById(0, UserID); objUserInfo.Membership.Approved = true; MembershipUser objUser = Membership.GetUser(objUserInfo.Username); string LsPassword = objUser.GetPassword(); UserController.UpdateUser(0, objUserInfo); CommonFn.SendSMS(objUserInfo.Profile.GetPropertyValue("PhoneNumber").Replace("-", string.Empty), "Thank you for verifying your mobile number, your login details for Jaslok is: Visitor ID- " + objUserInfo.Username + " and Password- " + LsPassword); setLoginFields(); lblLoginError.CssClass = "successText"; lblLoginError.Text = "User login details that has been sent to your registered mobile number"; } }
protected void btnSignUp_Click(object sender, EventArgs e) { lblSignUp.CssClass = ""; bool userExist = Convert.ToBoolean(objBusinessLogic.CheckUerExistence(ddlCountryCode.SelectedValue + "-" + txtMobileNumber.Text.Trim()).Rows[0]["MobileNumberExists"]); if (!userExist) { string lsUserName = string.Empty; string lsPassword = string.Empty; string lsOtp = Guid.NewGuid().ToString().ToUpper().Split('-')[0]; lsUserName = txtFirstName.Text.Substring(0, 1).ToLower() + txtLastName.Text.ToLower() + txtMobileNumber.Text.Substring(txtMobileNumber.Text.Length - 3, 3); lsPassword = RandomString(8); UserInfo oUser = new UserInfo(); oUser.PortalID = 0; oUser.IsSuperUser = false; oUser.FirstName = txtFirstName.Text; oUser.LastName = txtLastName.Text; oUser.Email = txtEmail.Text; oUser.Username = lsUserName; oUser.DisplayName = txtFirstName.Text; //oUser.Profile.ProfileProperties.Add oUser.Profile.PreferredLocale = PortalSettings.Current.DefaultLanguage; //oUser.Profile.PreferredTimeZone = PortalSettings.Current.TimeZone; oUser.Profile.FirstName = oUser.FirstName; oUser.Profile.LastName = oUser.LastName; oUser.Membership.Approved = false; //oUser.Membership.CreatedDate = System.DateTime.Now; oUser.Membership.Password = lsPassword; if (UserCreateStatus.Success == UserController.CreateUser(ref oUser)) { oUser = UserController.GetUserById(0, oUser.UserID); oUser.Profile.SetProfileProperty("Gender", ddlGender.SelectedValue); oUser.Profile.SetProfileProperty("Address", txtAddress.Text); oUser.Profile.SetProfileProperty("Age", txtAge.Text); oUser.Profile.SetProfileProperty("PhoneNumber", ddlCountryCode.SelectedValue + "-" + txtMobileNumber.Text.Trim()); oUser.Profile.SetProfileProperty("Email", txtEmail.Text); oUser.Profile.SetProfileProperty("OTP", lsOtp); oUser.Profile.SetProfileProperty("OTPCreatedDate", DateTime.Now.ToString()); UserController.UpdateUser(0, oUser); setOtPFields(); CommonFn.SendSMS(ddlCountryCode.SelectedValue + txtMobileNumber.Text.Trim(), "Your one time verification code is: " + lsOtp + ". This code will be valid for next 10 mins only."); lblOTPError.CssClass = "successText"; lblOTPError.Text = "OTP has been sent to your registered mobile number. On successfull verification of your mobile number you will receive your account details"; txtOTPPhoneNumber.Text = txtMobileNumber.Text.Trim(); ddlOTPCountryCode.SelectedValue = ddlCountryCode.SelectedValue; ddlOTPCountryCode.Enabled = false; txtEmail.Text = string.Empty; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; txtAge.Text = string.Empty; txtMobileNumber.Text = string.Empty; txtOTPPhoneNumber.Enabled = false; ddlOTPCountryCode.CssClass = "form-control"; txtOTPPhoneNumber.CssClass = "form-control"; ddlGender.SelectedValue = "Male"; ddlCountryCode.SelectedIndex = 0; try { //#region CSV Generation Code //DataTable dtUser = new DataTable(); //dtUser.Columns.Add("UserName", typeof(string)); //dtUser.Columns.Add("Email", typeof(string)); //dtUser.Columns.Add("Password", typeof(string)); //dtUser.Rows.Add(lsUserName, oUser.Email, lsPassword); //string PortalName = PortalSettings.Current.HomeDirectory; //if (!Directory.Exists(Server.MapPath(PortalName + "CsvFile"))) // Directory.CreateDirectory(Server.MapPath(PortalName + "CsvFile")); //string virtualFolder = PortalName + "CsvFile/"; //string FilePath = virtualFolder + "sample.csv"; //if (File.Exists(Server.MapPath(FilePath))) // File.Delete(Server.MapPath(FilePath)); //CreateCSVFile(dtUser, Server.MapPath(FilePath)); //#endregion } catch (Exception ex) { throw ex; } } else { lblSignUp.CssClass = "errorText"; lblSignUp.Text = "Problem in creating user. Please check all fields"; divLoginForm.Attributes.Add("style", "display:none;"); divSignUp.Attributes.Add("style", "display:block;"); } } else { lblSignUp.CssClass = "errorText"; lblSignUp.Text = "User with same mobile number already exists."; divLoginForm.Attributes.Add("style", "display:none;"); divSignUp.Attributes.Add("style", "display:block;"); } }
protected void btnForgotPasword_Click(object sender, EventArgs e) { JaslokMailer objMailer = new JaslokMailer(); List <Parameters> lstParameters = new List <Parameters>(); string lsEmailStatus = string.Empty; bool _isPermanentUser = objBusinessLogic.IsExistMrNo(txtForgotPasswordUserName.Text.Trim()); if (!_isPermanentUser) { MembershipUser objUser = Membership.GetUser(txtForgotPasswordUserName.Text.Trim()); if (objUser != null) { UserInfo objInfo = new UserInfo(); objInfo = UserController.GetUserByName(objUser.UserName); string lsmobileNumber = objInfo.Profile.GetPropertyValue("PhoneNumber"); string lsPassword; lsPassword = objUser.GetPassword(); //sendmail(objUser.Email, lsPassword); if (!string.IsNullOrEmpty(lsmobileNumber)) { CommonFn.SendSMS(lsmobileNumber.Replace("-", ""), "Your password is: " + lsPassword); } lstParameters.Add(new Parameters { ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text }); lstParameters.Add(new Parameters { ShortCodeName = "Password", ShortCodeValue = lsPassword }); lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, objInfo.Email, null); if (string.IsNullOrEmpty(lsEmailStatus)) { lblForgotPassError.Text = "Password has been sent to your email address."; lblForgotPassError.CssClass = "successText"; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } else { lblForgotPassError.Text = "Problem in sending email"; lblForgotPassError.CssClass = "errorText"; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } txtForgotPasswordUserName.Text = ""; //lblGeneratedPassword.Text = lsPassword; } else { lblForgotPassError.CssClass = "errorText"; lblForgotPassError.Text = "Username does not exist."; txtForgotPasswordUserName.Text = ""; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } } else { var PatientDetails = (dynamic)null; if (host.StartsWith("www.")) { PatientDetails = objPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtForgotPasswordUserName.Text.Trim()); } else { PatientDetails = objlocalPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtForgotPasswordUserName.Text.Trim()); } if (PatientDetails.WEBPWD != null) { if (!string.IsNullOrEmpty(PatientDetails.WEBPWD)) { CommonFn.SendSMS(PatientDetails.PatMobile.Replace("-", ""), "Your password is: " + PatientDetails.WEBPWD); } lstParameters.Add(new Parameters { ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text }); lstParameters.Add(new Parameters { ShortCodeName = "Password", ShortCodeValue = PatientDetails.WEBPWD }); lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, PatientDetails.PatEmail, null); if (string.IsNullOrEmpty(lsEmailStatus)) { lblForgotPassError.Text = "Password has been sent to your email address."; lblForgotPassError.CssClass = "successText"; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } else { lblForgotPassError.Text = "Problem in sending email"; lblForgotPassError.CssClass = "errorText"; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } txtForgotPasswordUserName.Text = ""; } else { lblForgotPassError.Text = "MRNumber not found, Please enter valid MRNumber."; lblForgotPassError.CssClass = "errorText"; divLoginForm.Attributes.Add("style", "display:none;"); divForgotPassword.Attributes.Add("style", "display:block;"); } } }
protected void btnSignUp_Click(object sender, EventArgs e) { lblSignUp.CssClass = ""; bool userExist = Convert.ToBoolean(objBusinessLogic.CheckUerExistence(ddlCountryCode.SelectedValue + "-" + txtMobileNumber.Text.Trim()).Rows[0]["MobileNumberExists"]); if (!userExist) { string lsUserName = string.Empty; string lsPassword = string.Empty; string lsOtp = Guid.NewGuid().ToString().ToUpper().Split('-')[0]; lsUserName = txtFirstName.Text.Substring(0, 1).ToLower() + txtLastName.Text.ToLower() + txtMobileNumber.Text.Substring(txtMobileNumber.Text.Length - 3, 3); lsPassword = RandomString(8); UserInfo oUser = new UserInfo(); oUser.PortalID = 0; oUser.IsSuperUser = false; oUser.FirstName = txtFirstName.Text; oUser.LastName = txtLastName.Text; oUser.Email = txtEmail.Text; oUser.Username = lsUserName; oUser.DisplayName = txtFirstName.Text; //oUser.Profile.ProfileProperties.Add oUser.Profile.PreferredLocale = PortalSettings.Current.DefaultLanguage; //oUser.Profile.PreferredTimeZone = PortalSettings.Current.TimeZone; oUser.Profile.FirstName = oUser.FirstName; oUser.Profile.LastName = oUser.LastName; oUser.Membership.Approved = false; //oUser.Membership.CreatedDate = System.DateTime.Now; oUser.Membership.Password = lsPassword; if (UserCreateStatus.Success == UserController.CreateUser(ref oUser)) { oUser = UserController.GetUserById(0, oUser.UserID); oUser.Profile.SetProfileProperty("Gender", ddlGender.SelectedValue); oUser.Profile.SetProfileProperty("Address", txtAddress.Text); oUser.Profile.SetProfileProperty("Age", txtAge.Text); oUser.Profile.SetProfileProperty("PhoneNumber", ddlCountryCode.SelectedValue + "-" + txtMobileNumber.Text.Trim()); oUser.Profile.SetProfileProperty("OTP", lsOtp); oUser.Profile.SetProfileProperty("OTPCreatedDate", DateTime.Now.ToString()); UserController.UpdateUser(0, oUser); setOtPFields(); CommonFn.SendSMS(ddlCountryCode.SelectedValue + txtMobileNumber.Text.Trim(), "Your one time verification code is: " + lsOtp + ". This code will be valid for next 10 mins only."); lblOTPError.CssClass = "successText"; lblOTPError.Text = "OTP has been sent to your registered mobile number. On successfull verification of your mobile number you will receive your account details"; txtOTPPhoneNumber.Text = txtMobileNumber.Text.Trim(); ddlOTPCountryCode.SelectedValue = ddlCountryCode.SelectedValue; ddlOTPCountryCode.Enabled = false; txtEmail.Text = string.Empty; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; txtAge.Text = string.Empty; txtMobileNumber.Text = string.Empty; txtOTPPhoneNumber.Enabled = false; ddlOTPCountryCode.CssClass = "form-control"; txtOTPPhoneNumber.CssClass = "form-control"; ddlGender.SelectedValue = "Male"; ddlCountryCode.SelectedIndex = 0; try { #region CSV Generation Code DataTable dtUser = new DataTable(); dtUser.Columns.Add("UserName", typeof(string)); dtUser.Columns.Add("Email", typeof(string)); dtUser.Columns.Add("Password", typeof(string)); dtUser.Rows.Add(lsUserName, oUser.Email, lsPassword); string PortalName = PortalSettings.Current.HomeDirectory; if (!Directory.Exists(Server.MapPath(PortalName + "CsvFile"))) { Directory.CreateDirectory(Server.MapPath(PortalName + "CsvFile")); } string virtualFolder = PortalName + "CsvFile/"; string FilePath = virtualFolder + "sample.csv"; if (File.Exists(Server.MapPath(FilePath))) { File.Delete(Server.MapPath(FilePath)); } CreateCSVFile(dtUser, Server.MapPath(FilePath)); #endregion } catch (Exception ex) { throw ex; } /*UserInfo objUser = new UserInfo(); * objUser.Username = lsUserName; * UserMembership objMembership = new UserMembership(objUser); * objMembership.Username = lsUserName; * objMembership.Password = lsPassword; * objMembership.Email = txtEmail.Text; * objUser.Membership = objMembership; * PortalSettings po = new PortalSettings(); * UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE; * UserInfo objUserInfo = UserController.ValidateUser(0, lsUserName, lsPassword, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus); * if (loginStatus == UserLoginStatus.LOGIN_SUCCESS || loginStatus == UserLoginStatus.LOGIN_SUPERUSER) * { * UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true); * lstParameters.Add(new Parameters { ShortCodeName = "Username", ShortCodeValue = lsUserName }); * lsEmailStatus = objMailer.SendEmail("registration", lstParameters, txtEmail.Text); * if (string.IsNullOrEmpty(lsEmailStatus)) * { * lblError.Text = "Password has been sent to your email address."; * lblError.CssClass = "successText"Green; * } * Response.Redirect("/"); * }*/ } else { lblSignUp.CssClass = "errorText"; lblSignUp.Text = "Problem in creating user. Please check all fields"; } } else { lblSignUp.CssClass = "errorText"; lblSignUp.Text = "User with same mobile number already exists."; } }