/// <summary> /// To check whether the user is a valid user /// </summary> /// <param name="UserName">User name</param> /// <param name="Password">password</param> /// <returns></returns> public bool CheckIsValidUser(string UserName, string Password) { object[] objUserCredentials = new object[2]; objUserCredentials[0] = UserName; objUserCredentials[1] = encDecryption.Encrypt(Password); System.Data.DataSet userData = DataLibrary.ExecuteDataSet(ref objUserCredentials, "bspAuthorizeUserLogIn"); if (userData.Tables.Count > 0) { if (userData.Tables[0].Rows.Count > 0) { DataTable userDataTable = userData.Tables[0]; var resultSet = userDataTable.AsEnumerable().Select(result => new { UserName = result.Field <string>("userid"), DisplayName = result.Field <string>("DisplayName"), CompanyId = result.Field <int?>("CompanyId") }).FirstOrDefault(); Resources.DisplayName = resultSet.DisplayName; userSession.SetSession("CompanyId", resultSet.CompanyId); userSession.SetSession("DisplayName", resultSet.DisplayName); userData = null; userDataTable = null; if (UserName.ToLower() == resultSet.UserName.ToLower()) { return(true); } else { return(false); } } else { return(false); } } else { return(false); } }
public ActionResult ForgotPassword(ForgotPasswordViewModel forgotPasswordViewModel) { string statusMessage = Messages.ErrorSendingEmail; if (ModelState.IsValid) { using (userRepository) { string resettedPassword = Zaretto.PasswordGenerator.Creator.Generate(12); string[] forgottenPasswordResult = webFormsAuthentication.ResetPassword(forgotPasswordViewModel.email, encDecryption.Encrypt(resettedPassword)); string mesageBody = string.Empty; if (forgottenPasswordResult != null) { if (forgottenPasswordResult.Length > 0) { forgottenPasswordResult[1] = encDecryption.Decrypt(forgottenPasswordResult[1]); mesageBody = mailer.MailContentBuilder(Messages.ForgottenPasswordEmailBody, forgottenPasswordResult); mailer.SetMailData(forgotPasswordViewModel.email, Messages.ForgottenPasswordEmailSubject, mesageBody, true, true); statusMessage = mailer.SendMail() ? Messages.ForgottenPasswordResetSucess : Messages.ForgottenPasswordResetFailure; TempData["statusMessage"] = statusMessage; return(RedirectToAction("Messager")); } } else { TempData["statusMessage"] = Messages.UserEmailNotExists; return(RedirectToAction("Messager")); } } statusMessage = Messages.ErrorRecoverPassword; } TempData["statusMessage"] = statusMessage; return(RedirectToAction("Messager")); }
public JsonResult InviteAFriend(string userId) { DataSet userDetailSet = iFriendInvitationRepository.GetUserDetails(userId); bool invitationStatus = false; if (userDetailSet.Tables.Count > 0) { UserDetailsViewModel userDetailsViewModel = userDetailSet.Tables[0].AsEnumerable().Select(result => new UserDetailsViewModel { UserId = result.Field <string>("UserId"), UserName = result.Field <string>("UserName"), EmailId = result.Field <string>("EmailId"), CompanyId = result.Field <int>("CompanyId"), CompanyName = result.Field <string>("CompanyName") }).FirstOrDefault(); var hostName = Resources.GetHostName(HttpContext.Request.Url.ToString()); string mailContent = mailer.MailContentBuilder(Messages.InviteFriendToCompanyEmailBody, new string[] { userDetailsViewModel.UserName, hostName, Url.Action("AcceptInvitation", "InviteFriends", new { area = "InviteFriends", userName = userDetailsViewModel.UserId, verfid = encDecryption.Encrypt(Convert.ToString(userSession.CompanyId)) }), User.Identity.Name }); mailer.SetMailData(userDetailsViewModel.EmailId, string.Format("Invitation from {0}", User.Identity.Name), mailContent, true, true); invitationStatus = mailer.SendMail() ? iFriendInvitationRepository.LogInvitation(userId, SessionUserId, userDetailsViewModel.CompanyId.GetDefaultValueIfNull <string>()) : false; } return(Json(invitationStatus, JsonRequestBehavior.AllowGet)); }