public EmployeeWraperFull ChangeUserPassword(Guid userid, String password, String email) { SecurityContext.DemandPermissions(new UserSecurityProvider(userid), Core.Users.Constants.Action_EditUser); if (!CoreContext.UserManager.UserExists(userid)) { return(null); } var user = CoreContext.UserManager.GetUsers(userid); if (CoreContext.UserManager.IsSysytemUser(user.ID)) { throw new SecurityException(); } if (!string.IsNullOrEmpty(email)) { var address = new MailAddress(email); if (!string.Equals(address.Address, user.Email, StringComparison.OrdinalIgnoreCase)) { user.Email = address.Address.ToLowerInvariant(); user.ActivationStatus = EmployeeActivationStatus.Activated; CoreContext.UserManager.SaveUserInfo(user); } } if (!string.IsNullOrEmpty(password)) { SecurityContext.SetUserPassword(userid, password); } return(new EmployeeWraperFull(GetUserInfo(userid.ToString()))); }
public object SaveData(string email, string pwd, string lng, string promocode, string amiid, bool analytics) { try { var tenant = CoreContext.TenantManager.GetCurrentTenant(); var settings = WizardSettings.Load(); if (settings.Completed) { throw new Exception("Wizard passed."); } if (IsAmi && IncorrectAmiId(amiid)) { throw new Exception(Resource.EmailAndPasswordIncorrectAmiId); } if (tenant.OwnerId == Guid.Empty) { Thread.Sleep(TimeSpan.FromSeconds(6)); // wait cache interval tenant = CoreContext.TenantManager.GetTenant(tenant.TenantId); if (tenant.OwnerId == Guid.Empty) { LogManager.GetLogger("ASC.Web.FirstTime").Error(tenant.TenantId + ": owner id is empty."); } } var currentUser = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId); var cookie = SecurityContext.AuthenticateMe(currentUser.ID); CookiesManager.SetCookies(CookiesType.AuthKey, cookie); if (!UserManagerWrapper.ValidateEmail(email)) { throw new Exception(Resource.EmailAndPasswordIncorrectEmail); } UserManagerWrapper.CheckPasswordPolicy(pwd); SecurityContext.SetUserPassword(currentUser.ID, pwd); email = email.Trim(); if (currentUser.Email != email) { currentUser.Email = email; currentUser.ActivationStatus = EmployeeActivationStatus.NotActivated; } CoreContext.UserManager.SaveUserInfo(currentUser); if (!string.IsNullOrWhiteSpace(promocode)) { try { CoreContext.PaymentManager.ActivateKey(promocode); } catch (Exception err) { LogManager.GetLogger("ASC.Web.FirstTime").Error("Incorrect Promo: " + promocode, err); throw new Exception(Resource.EmailAndPasswordIncorrectPromocode); } } if (RequestLicense) { TariffSettings.LicenseAccept = true; MessageService.Send(HttpContext.Current.Request, MessageAction.LicenseKeyUploaded); LicenseReader.RefreshLicense(); } if (TenantExtra.Opensource) { settings.Analytics = analytics; } settings.Completed = true; settings.Save(); TrySetLanguage(tenant, lng); StudioNotifyService.Instance.SendCongratulations(currentUser); FirstTimeTenantSettings.SendInstallInfo(currentUser); return(new { Status = 1, Message = Resource.EmailAndPasswordSaved }); } catch (BillingNotFoundException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseKeyNotFound }); } catch (BillingNotConfiguredException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseKeyNotCorrect }); } catch (BillingException) { return(new { Status = 0, Message = UserControlsCommonResource.LicenseException }); } catch (Exception ex) { LogManager.GetLogger("ASC.Web.FirstTime").Error(ex); return(new { Status = 0, Message = ex.Message }); } }