protected void btnlogin_Click(object sender, EventArgs e) { Usr = UserManager.GetUserByEmail(txtuserid.Text); bool bIsAuthenticated = false; if (Usr != null) { if (EncryptionHelper.Decrypt(Usr.Password) == txtpassword.Text) { if (Usr.IsLoginAllowed == false) { lblFeedback.Visible = true; lblFeedback.Text = "Login is disabled. Please contact admin."; lblFeedback.ForeColor = System.Drawing.Color.Red; return; } else if (Usr.IsDeleted == true) { lblFeedback.Text = "Your account has been deleted. Please contact administrator."; lblFeedback.Visible = true; lblFeedback.ForeColor = System.Drawing.Color.Red; return; } else if (Usr.IsEmailVerified == false) { lblFeedback.Text = "Your email has not been verified. Please verify it before login."; lblFeedback.Visible = true; lblFeedback.ForeColor = System.Drawing.Color.Red; return; } else { Session["UserID"] = Usr.EmailId; Session["Username"] = Usr.Customer.FirstName + " " + Usr.Customer.LastName; } bIsAuthenticated = true; } } if (!bIsAuthenticated) { lblFeedback.Text = "Invalid Email Address or Password"; lblFeedback.ForeColor = System.Drawing.Color.Red; lblFeedback.Visible = true; return; } else { Response.Redirect("~/WebPortal/HomePage.aspx"); } }
public static bool ChangePassword(UserLogin user) { using (WebPresenceEntities _context = new WebPresenceEntities()) { var NewPassword = (from n in _context.UserLogins where n.EmailId == user.EmailId select n).First(); NewPassword.Password = user.Password; int i = _context.SaveChanges(); if (i > 0) return true; else return false; } }
public static string InsertOrUpdateUserLogin(UserLogin usr) { try { using (WebPresenceEntities _context = new WebPresenceEntities()) { if (usr.Id > 0) { _context.UserLogins.Single(o => o.Id == usr.Id); _context.UserLogins.ApplyCurrentValues(usr); } else { _context.UserLogins.AddObject(usr); } _context.SaveChanges(); return usr.Id.ToString(); } } catch (Exception ex) { return ex.Message; } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { try { UserLogin user = new UserLogin(); user = UserManager.GetUserByEmail(txtEmail.Text); if (user != null) { lblEmailExists.Visible = true; return; } lblEmailExists.Visible = false; UserLogin UserObj = new UserLogin(); Customer CustomObject = new Customer(); CustomObject.FirstName = txtFirstName.Text; CustomObject.LastName = txtLastName.Text; CustomObject.Address = TexAddrress.Text; CustomObject.City = TextCity.Text; CustomObject.ContactNo = TexContact.Text; CustomObject.State = DropDownState.SelectedValue; CustomObject.Country = "USA"; CustomObject.PostalCode = TexPostal.Text; CustomObject.PackageFk = 1; CustomObject.IsCancelled = false; CustomObject.DateCancelled = CommonClass.CurrentTime(); if (usertupeId.Value == "1") { CustomObject.NextPaymentDate = DateTime.Now.AddDays(14); } else if (usertupeId.Value == "2") { CustomObject.NextPaymentDate = DateTime.Now.AddDays(7); } else { CustomObject.NextPaymentDate = DateTime.Now.AddDays(7); } CustomObject.IsFreeTrial = true; CustomObject.IsActive = true; CustomObject.IsDeleted = false; CustomObject.CreatedBy = 1; CustomObject.CreatedDate = DateTime.Now; CustomObject.DateCreated = CommonClass.CurrentTime(); CustomObject.DateUpdated = CommonClass.CurrentTime(); Customers objects = new Customers(); string id = objects.InsertOrUpdateUser(CustomObject); if (Convert.ToInt32(id) > 0) { Guid objGuid = Guid.NewGuid(); string uniqueID = objGuid.ToString().Substring(0, 8); UserObj.RoleId = Convert.ToInt32(usertupeId.Value); UserObj.CustomerId = Convert.ToInt32(id); UserObj.EmailId = txtEmail.Text; UserObj.Password = EncryptionHelper.Encrypt(txtPassword.Text); UserObj.IsClient = false; UserObj.LastLoginDate = CommonClass.CurrentTime(); UserObj.EmailVerificationCode = uniqueID; UserObj.IsEmailVerified = false; UserObj.PassWordResetCode = uniqueID; UserObj.IsLoginAllowed = false; UserObj.IsDeleted = false; UserObj.CreatedBy = 1; UserObj.CreatedDate = CommonClass.CurrentTime(); int UserLoginid = Convert.ToInt32(UserManager.InsertOrUpdateUserLogin(UserObj)); if (UserLoginid > 0) { string link = "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + "/WebPresence/EmailVerification.aspx?Email=" + txtEmail.Text + "&UserID=" + id + "&Code=" + uniqueID; string mailBody = "<table style='width:100%;'><tr><td width='25%'>Dear " + txtFirstName.Text + " " + txtLastName.Text + ",</td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr><tr><td colspan='4'>An email verification code is being sending to you by webpresence team.Please find it below :</td></tr><tr><td width='25%'>" + link + "</td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr><tr><td colspan='4'>You can verify your email by clicking at the link</td></tr><tr><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr><tr><td width='25%'>Thanks & Regards,</td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr><tr><td width='25%'>WebPresence Team</td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr><tr><td width='25%'>" + "http://" + System.Web.HttpContext.Current.Request.Url.Host.ToString() + "/WebPresence/" + "</td><td width='25%'> </td><td width='25%'> </td><td width='25%'> </td></tr></table>"; //<tr><td width='25%'>Verification Code :</td><td width='25%'>" + uniqueID + "</td><td width='25%'> </td><td width='25%'> </td></tr> string mailSubject = "Email Verification Code From WebPresence"; SendMail.SendEmail(mailBody, mailSubject, txtEmail.Text); if (CustomObject.IsFreeTrial == false) Response.Redirect("Signup2.aspx"); ClearControls(); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AlertMessage", "alert('Signup process failed! Please try again.');", true); } } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AlertMessage", "alert('Signup process failed! Please try again.');", true); } } catch (Exception ex) { throw ex; } } }
public static UserLogin RecoverPassword(UserLogin user) { using (WebPresenceEntities _context = new WebPresenceEntities()) { return (from login in _context.UserLogins where login.EmailId.Equals(user.EmailId) select login).FirstOrDefault(); } }
/// <summary> /// Deprecated Method for adding a new object to the UserLogins EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUserLogins(UserLogin userLogin) { base.AddObject("UserLogins", userLogin); }
/// <summary> /// Create a new UserLogin object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="roleId">Initial value of the RoleId property.</param> /// <param name="customerId">Initial value of the CustomerId property.</param> /// <param name="emailId">Initial value of the EmailId property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="isClient">Initial value of the IsClient property.</param> /// <param name="lastLoginDate">Initial value of the LastLoginDate property.</param> /// <param name="emailVerificationCode">Initial value of the EmailVerificationCode property.</param> /// <param name="isEmailVerified">Initial value of the IsEmailVerified property.</param> /// <param name="passWordResetCode">Initial value of the PassWordResetCode property.</param> /// <param name="isLoginAllowed">Initial value of the IsLoginAllowed property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> /// <param name="createdBy">Initial value of the CreatedBy property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> public static UserLogin CreateUserLogin(global::System.Int32 id, global::System.Int32 roleId, global::System.Int32 customerId, global::System.String emailId, global::System.String password, global::System.Boolean isClient, global::System.DateTime lastLoginDate, global::System.String emailVerificationCode, global::System.Boolean isEmailVerified, global::System.String passWordResetCode, global::System.Boolean isLoginAllowed, global::System.Boolean isDeleted, global::System.Int32 createdBy, global::System.DateTime createdDate) { UserLogin userLogin = new UserLogin(); userLogin.Id = id; userLogin.RoleId = roleId; userLogin.CustomerId = customerId; userLogin.EmailId = emailId; userLogin.Password = password; userLogin.IsClient = isClient; userLogin.LastLoginDate = lastLoginDate; userLogin.EmailVerificationCode = emailVerificationCode; userLogin.IsEmailVerified = isEmailVerified; userLogin.PassWordResetCode = passWordResetCode; userLogin.IsLoginAllowed = isLoginAllowed; userLogin.IsDeleted = isDeleted; userLogin.CreatedBy = createdBy; userLogin.CreatedDate = createdDate; return userLogin; }