public ActionResult VerifyEmailAddress(string GUID) { var user = userRepository.Users.Where(uid => uid.GUID == GUID).FirstOrDefault(); if (user != null) { bool resUser = userRepository.ActiveEmialVerification(user); //Session["ChangePassword"] = "******"; if (resUser) { //create a session for the user. var pass = Encryption.DecryptStringAES(user.Password, rand); if (authProvider.Authenticate(user.Email, pass, userRepository)) { Session["user"] = userRepository.GetUserByEmailAddress(user.Email); //Session["folderss"] = null; User userObj = (User)Session["user"]; var accountObj = accRepository.Accounts.FirstOrDefault(x => x.ID == userObj.AccountID); Session["account"] = accountObj; var folders = CCFolderRepository.CCFolders.Where(guid => guid.AccountGUID == accountObj.AccountGUID).ToList(); Session["folderss"] = folders; List<NotificationListViewModel> notificationList = new List<NotificationListViewModel>(); HelperFunctions HF = new HelperFunctions(); notificationList = HF.generateNotificationList(accountObj); if (notificationList.Count > 0) Session["notifications"] = notificationList; else Session["notifications"] = null; } ViewBag.VerifiedMessageSucess = "You have successfully activated your user account."; ViewBag.VerifiedMessageFail = ""; } else { ViewBag.VerifiedMessageFail = "Failed to activate your account."; ViewBag.VerifiedMessageSucess = ""; } } else { ViewBag.VerifiedMessageFail = "Sorry, We couldn't find your account."; ViewBag.VerifiedMessageSucess = ""; } return View(); }
public ActionResult Login(LogOnViewModel model, string returnUrl) { if (ModelState.IsValid) { if (authProvider.Authenticate(model.EmailAddress, model.Password, this.userRepository)) { var userObj = userRepository.GetUserByEmailAddress(model.EmailAddress); Session["user"] = userObj; var accountObj = accRepository.Accounts.FirstOrDefault(x => x.ID == userObj.AccountID); Session["account"] = accountObj; var timeZone = accRepository.Accounts.Where(aid => aid.ID == userObj.AccountID).FirstOrDefault().TimeZone; Session["timeZone"] = timeZone; Session["SysAdminDetails"] = null; List<NotificationListViewModel> notificationList = new List<NotificationListViewModel>(); CronJobController CJC = new CronJobController(); Session["account"] = CJC.checkAccountTrialExpiryForAccount(accountObj); //save details into error table //SaveLogonDetails(model.EmailAddress); if ( userObj.UserType == "Admin" || userObj.UserType == "Standard") { if (userObj.EmailVerified == true) { //get the folders var folders = CCFolderRepository.CCFolders.Where(guid => guid.AccountGUID == accountObj.AccountGUID).ToList(); Session["folderss"] = folders; HelperFunctions HF = new HelperFunctions(); notificationList = HF.generateNotificationList(accountObj); HF.CheckAcccountStatus(accountObj); if(notificationList.Count>0) Session["notifications"] = notificationList; else Session["notifications"] = null; return Redirect(returnUrl ?? Url.Action("Index", "Admin")); } else { return Redirect(returnUrl ?? Url.Action("ResendVerification", "SignUp", new { uid = userObj.ID })); } } else if (userObj.UserType == "SystemAdmin") { HelperFunctions HF = new HelperFunctions(); notificationList = HF.generateNotificationList(accountObj); if (notificationList.Count > 0) Session["notifications"] = notificationList; Session["SysAdminDetails"] = userRepository.GetUserByEmailAddress(model.EmailAddress); return Redirect(returnUrl ?? Url.Action("Index", "CorporateContactsAdmin")); } else { return Redirect(returnUrl ?? Url.Action("SetupSync", "User")); } } else { //save details into error table //SaveLogonDetails(model.EmailAddress); ModelState.AddModelError("", "Incorrect username or password"); return View(); } } else { return View(); } }
public ActionResult ImpersonatedAccount(long AccID) { if (Session["SysAdminDetails"] != null) { TempData["SelectedMenu"] = "AccImpersontation"; var userObj = CCUserRepository.GetUserByEmailAddress(CCUserRepository.Users.First(U => U.AccountID == AccID).Email); Session["user"] = userObj; var accountObj = CCAccRepository.Accounts.FirstOrDefault(x => x.ID == userObj.AccountID); Session["account"] = accountObj; var timeZone = CCAccRepository.Accounts.Where(aid => aid.ID == userObj.AccountID).FirstOrDefault().TimeZone; Session["timeZone"] = timeZone; var folders = CCFolderRepository.CCFolders.Where(guid => guid.AccountGUID == accountObj.AccountGUID).ToList(); Session["folderss"] = folders; LimitationsViewModel limitationsObj = new LimitationsViewModel(); HelperFunctions HF1 = new HelperFunctions(); limitationsObj = HF1.updateAccountLimitations(accountObj); Session["limitations"] = limitationsObj; List<NotificationListViewModel> notificationList = new List<NotificationListViewModel>(); CronJobController CJC = new CronJobController(); Session["account"] = CJC.checkAccountTrialExpiryForAccount(accountObj); HelperFunctions HF = new HelperFunctions(); notificationList = HF.generateNotificationList(accountObj); HF.CheckAcccountStatus(accountObj); if (notificationList.Count > 0) Session["notifications"] = notificationList; else Session["notifications"] = null; if (((DateTime)(accountObj.TrialEnds) - (DateTime)(DateTime.Now.Date)).TotalDays < CCGlobalValues.trialPeriod) { TrialDataModel trialObj = new TrialDataModel(); trialObj.hasPurchased = accountObj.HasPurchased; trialObj.createdDate = accountObj.CreatedDate; trialObj.trialEndDate = accountObj.TrialEnds; trialObj.showPurchaseOptions = true; Session["trialData"] = trialObj; } ImpersonateAccountsSysAdminModel model = new ImpersonateAccountsSysAdminModel(); var AccountsInfo = CCAccRepository.Accounts.Where(A => A.ID == AccID).FirstOrDefault(); model.SelectedAccountInfo = AccountsInfo; model.FolderCount = CCFolderRepository.CCFolders.Where(F => F.AccountGUID == AccountsInfo.AccountGUID).Count(); model.ConnectionCount = CCConnectionRepository.CCSubscriptions.Where(C => C.AccountGUID == AccountsInfo.AccountGUID).Count(); model.UserCount = CCUserRepository.Users.Where(U => U.AccountID == AccountsInfo.ID).Count(); model.SubscriptionCount = 0; model.ItemsCount = CCItemRepository.CCContacts.Where(I => I.AccountGUID == AccountsInfo.AccountGUID).Count(); model.SelectedAccountOwner = CCUserRepository.Users.First(U => U.AccountID == AccountsInfo.ID).FullName; //Sync Graph Data List<string> SyncDates = new List<string>(); List<double> SyncDateUsage = new List<double>(); DateTime startDate = DateTime.Now.Date.AddDays(-1); for (int i = 6; i > -1; i--) { SyncDates.Add((startDate.AddDays(-i)).ToShortDateString()); } for (int i = 0; i < SyncDates.Count(); i++) { DateTime syncDateStart = DateTime.Parse(SyncDates[i]); DateTime syncDateEnd = syncDateStart.AddHours(23).AddMinutes(59); SyncDateUsage.Add(CCSyncItemsRepository.CCSyncItems.Where(SI => SI.LastUpdated >= syncDateStart && SI.LastUpdated <= syncDateEnd).Count()); } model.SyncDates = SyncDates; model.SyncDateUsage = SyncDateUsage; return View(model); } else { return RedirectToAction("Login", "Login"); } }