public ActionResult ForgotPassword(string email) { string message = ""; bool status = false; using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var account = dc.Users.FirstOrDefault(a => a.Email == email); if (account != null) { string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword"); account.ResetPasswordCode = resetCode; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "Reset password link has been sent to your email id."; } else { message = "Account not found"; } } ViewBag.Message = message; return(View()); }
public bool IsEmailExist(string emailID) { using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var v = dc.Users.FirstOrDefault(a => a.Email == emailID); return(v != null); } }
public ActionResult Login(UserLogin login, string ReturnUrl = "") { string message = ""; using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var v = dc.Users.FirstOrDefault(a => a.Email == login.Email); if (v != null) { if (!v.IsEmailVerified) { ViewBag.Message = "Please verify your email first"; return(View()); } if (String.CompareOrdinal(Crypto.Hash(login.Password), v.Password) == 0) { int timeout = login.RememberMe ? 525600 : 20; // 525600 min = 1 year var ticket = new FormsAuthenticationTicket(login.Email, login.RememberMe, timeout); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); Session["User"] = login.Email; Session["UserName"] = v.UserName; #region AddLogin info var logininfo = new LoginInfo(); logininfo.UserId = v.UserId; logininfo.LogInTime = DateTime.Now; logininfo.LoginIp = Request.UserHostAddress; dc.LoginInfoes.Add(logininfo); dc.SaveChanges(); #endregion if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { return(RedirectToAction("Index", "Registration")); } } else { message = "Invalid credential provided"; } } else { message = "Invalid credential provided"; } } ViewBag.Message = message; return(View()); }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user) { bool Status = false; string message = ""; // // Model Validation if (ModelState.IsValid) { #region //Email is already Exist var isExist = IsEmailExist(user.Email); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(user)); } #endregion #region Generate Activation Code user.ActivationCode = Guid.NewGuid().ToString(); #endregion #region Password Hashing user.Password = Crypto.Hash(user.Password); #endregion user.IsEmailVerified = false; user.RegistrationDate = DateTime.Now; #region Save to Database using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { dc.Users.Add(user); dc.SaveChanges(); //Send Email to User SendVerificationLinkEmail(user.Email, user.ActivationCode.ToString()); message = "Registration successfully done. Account activation link " + " has been sent to your email id:" + user.Email; Status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = Status; return(View(user)); }
public ActionResult RegisterUser(ChatUser chatUser) { if (chatUser != null) { ChatUser user = new ChatUser(); user.ChatUserName = chatUser.ChatUserName; using (AlphasoftWebsiteContext db = new AlphasoftWebsiteContext()) { db.ChatUsers.Add(user); db.SaveChanges(); } Session["UserName"] = chatUser.ChatUserName; return(View()); } return(View()); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var v = dc.Users.FirstOrDefault(a => a.ActivationCode == new Guid(id).ToString()); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }
public ActionResult ResetPassword(string id) { if (string.IsNullOrWhiteSpace(id)) { return(HttpNotFound()); } using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var user = dc.Users.FirstOrDefault(a => a.ResetPasswordCode == id); if (user != null) { ResetPassword model = new ResetPassword(); model.ResetCode = id; return(View(model)); } else { return(HttpNotFound()); } } }
public ActionResult ResetPassword(ResetPassword model) { var message = ""; if (ModelState.IsValid) { using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext()) { var user = dc.Users.FirstOrDefault(a => a.ResetPasswordCode == model.ResetCode); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; #region Add ResetPassword info var resetpassword = new ResetPassword(); resetpassword.UserId = user.UserId; resetpassword.ResetCode = model.ResetCode; resetpassword.NewPassword = user.Password; resetpassword.ResetTime = DateTime.Now; dc.ResetPasswords.Add(resetpassword); #endregion dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "New password updated successfully"; } } } else { message = "Something invalid"; } ViewBag.Message = message; return(View(model)); }
public PricingTableTypeRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public BlogRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public ChatUserRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public IconListManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iIconListRepository = new IconListRepository(_AlphasoftWebsiteContext); }
public ServiceRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public FactorDetailsRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public ServiceManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iServiceRepository = new ServiceRepository(_AlphasoftWebsiteContext); }
public FAQHeaderManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iFAQHeaderRepository = new FAQHeaderRepository(_AlphasoftWebsiteContext); }
public ConnectionPropertiesRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public CommonManager() { _dbContext = new AlphasoftWebsiteContext(); _iCommonRepository = new CommonRepository(_dbContext); }
public BlogCategoryManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iBlogCategoryRepository = new BlogCategoryRepository(_AlphasoftWebsiteContext); }
public FeatureHeaderRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public ClientManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iClientRepository = new ClientRepository(_AlphasoftWebsiteContext); }
public SmtpHostManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iSmtpHostRepository = new SmtpHostRepository(_AlphasoftWebsiteContext); }
public PricingTableTypeManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iPricingTableTypeRepository = new PricingTableTypeRepository(_AlphasoftWebsiteContext); }
public PricingDetailRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public NewsletterMailRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public EmployeeManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iEmployeeRepository = new EmployeeRepository(_AlphasoftWebsiteContext); }
public FeatureDetailRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public WebSiteHomeRepository(AlphasoftWebsiteContext dbContext) { _dbContext = dbContext; }
public SoftwareCategoryManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iSoftwareCategoryRepository = new SoftwareCategoryRepository(_AlphasoftWebsiteContext); }
public CompanySocialAccountDetailManager() { _AlphasoftWebsiteContext = new AlphasoftWebsiteContext(); _iCompanySocialAccountDetailRepository = new CompanySocialAccountDetailRepository(_AlphasoftWebsiteContext); }