public Boolean HasAccess(Data.Model.User currentUser, Data.Model.User currentUserCreated) { bool hasAccess = true; if (currentUser != null) { if (RequiresSuperAdminRole && (!currentUser.IsSuperAdmin() && !currentUser.IsCommercial())) { hasAccess = false; } if (RequiresAdviserConfigRole && !currentUser.CanConfigAdviser()) { hasAccess = false; } if (RequiresClientConfigRole && !currentUser.CanConfigClient()) { hasAccess = false; } if (RequiresFirmConfigRole && !currentUser.CanConfigFirm()) { hasAccess = false; } if ((RequiresReassignConfigRole && !currentUser.IsEndUser() && !currentUser.CanReassignClientProspects()) || (RequiresReassignConfigRole && currentUser.IsEndUser() && currentUserCreated != null && !currentUserCreated.CanReassignClientProspects())) { hasAccess = false; } if ((RequiresAggregatorLicense && !currentUser.IsEndUser() && !currentUser.HasAggregatorLicense()) || (RequiresAggregatorLicense && currentUser.IsEndUser() && currentUserCreated != null && !currentUserCreated.HasAggregatorLicense())) { hasAccess = false; } else if (RequiresReportLABLicense && (!currentUser.HasReportLicense() && !currentUser.HasLABLicense() && !currentUser.IsEndUser())) { hasAccess = false; } } return hasAccess; }
public static Boolean SendResetPasswordEmail(Data.Model.User user, out String message) { try { //string siteUrl = Upsilab.Business.Utility.UrlHelper.GetSiteUrl(); string siteUrl = string.Empty; String from = ConfigurationManager.ResetPasswordEmailFrom; if (user.IsEndUser()) { siteUrl = string.Format("{0}/Client", Upsilab.Business.Utility.UrlHelper.GetHost()); Data.Model.CustomerProspect customer = CustomerProspectBL.GetCustomerProspectByIdUser(user.idUser); from = customer.User1.UserEmail; } else if (user.IsSuperAdmin()) { siteUrl = string.Format("{0}/Admin", Upsilab.Business.Utility.UrlHelper.GetHost()); } else { siteUrl = string.Format("{0}/User", Upsilab.Business.Utility.UrlHelper.GetHost()); } string token = HttpServerUtility.UrlTokenEncode(new System.Text.ASCIIEncoding().GetBytes((UserBL.CreateSecureToken(user)))); string urlResetPwd = string.Format("{0}/User/ResetPassword?token={1}", siteUrl, token); var template = EmailManager.GetEmailTemplateContentByName(EmailManager.ResetPassword); string subject = LanguageContentBL.Translate("mailResetPassword");//Réinitialisation de votre mot de passe sur www.upsideo.fr string emailMessage = string.Format(template, urlResetPwd); UserAuthentication userAuth = new UserAuthentication() { UserAuthToken = token, IsValid = true, DateCreated = DateTime.Now, idUser = user.idUser }; UserAuthentificationBL.CreateUserAuthentication(userAuth); EmailManager.SendEmail(from, user.UserEmail, String.Empty, subject, emailMessage); //Log mail EmailLogBL.TypeDestinataire typeDestinaire = EmailLogBL.TypeDestinataire.Admin; if (user.IsEndUser()) typeDestinaire = EmailLogBL.TypeDestinataire.Client; else if (user.IsAdmin()) typeDestinaire = EmailLogBL.TypeDestinataire.Admin; else if (user.IsAdviser()) typeDestinaire = EmailLogBL.TypeDestinataire.Adviser; EmailLogBL.Log(null, from, user.idUser, user.UserEmail, typeDestinaire, System.Reflection.MethodBase.GetCurrentMethod().Name); message = LanguageContentBL.Translate("messageResetPassword");//L'email de réinitialisation de mot de passe a été envoyé avec succès ! return true; } catch (Exception ex) { message = ex.Message; return false; } }