Merge branch 'feature/new-login-page' of github.com:ONLYOFFICE/AppServer into feature/new-login-page

This commit is contained in:
Vladislav Makhov 2020-07-22 17:00:45 +03:00
commit ee21cb1a8b
5 changed files with 171 additions and 0 deletions

View File

@ -31,6 +31,7 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.ServiceModel.Security;
using System.Text.RegularExpressions;
using System.Web;
using ASC.Api.Collections;
@ -247,10 +248,64 @@ namespace ASC.Api.Settings
settings.OwnerId = Tenant.OwnerId;
settings.NameSchemaId = CustomNamingPeople.Current.Id;
}
else
{
settings.EnabledJoin =
(Tenant.TrustedDomainsType == TenantTrustedDomainsType.Custom &&
Tenant.TrustedDomains.Count > 0) ||
Tenant.TrustedDomainsType == TenantTrustedDomainsType.All;
var studioAdminMessageSettings = SettingsManager.Load<StudioAdminMessageSettings>();
settings.EnableAdmMess = studioAdminMessageSettings.Enable || TenantExtra.IsNotPaid();
}
return settings;
}
[Create("messagesettings")]
public string EnableAdminMessageSettings(AdminMessageSettingsModel model)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
SettingsManager.Save(new StudioAdminMessageSettings { Enable = model.TurnOn });
MessageService.Send(MessageAction.AdministratorMessageSettingsUpdated);
return Resource.SuccessfullySaveSettingsMessage;
}
[Create("maildomainsettings")]
public string SaveMailDomainSettings(MailDomainSettingsModel model)
{
PermissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (model.Type == TenantTrustedDomainsType.Custom)
{
Tenant.TrustedDomains.Clear();
foreach (var d in model.Domains.Select(domain => (domain ?? "").Trim().ToLower()))
{
if (!(!string.IsNullOrEmpty(d) && new Regex("^[a-z0-9]([a-z0-9-.]){1,98}[a-z0-9]$").IsMatch(d)))
return Resource.ErrorNotCorrectTrustedDomain;
Tenant.TrustedDomains.Add(d);
}
if (Tenant.TrustedDomains.Count == 0)
model.Type = TenantTrustedDomainsType.None;
}
Tenant.TrustedDomainsType = model.Type;
SettingsManager.Save(new StudioTrustedDomainSettings { InviteUsersAsVisitors = model.InviteUsersAsVisitors });
TenantManager.SaveTenant(Tenant);
MessageService.Send(MessageAction.TrustedMailDomainSettingsUpdated);
return Resource.SuccessfullySaveSettingsMessage;
}
[Read("customschemas")]
public List<SchemaModel> PeopleSchemas()
{

View File

@ -0,0 +1,18 @@
using System.Collections.Generic;
using ASC.Core.Tenants;
namespace ASC.Web.Api.Models
{
public class MailDomainSettingsModel
{
public TenantTrustedDomainsType Type { get; set; }
public List<string> Domains { get; set; }
public bool InviteUsersAsVisitors { get; set; }
}
public class AdminMessageSettingsModel
{
public bool TurnOn { get; set; }
}
}

View File

@ -51,6 +51,10 @@ namespace ASC.Api.Settings
public string NameSchemaId { get; set; }
public bool? EnabledJoin { get; set; }
public bool? EnableAdmMess { get; set; }
public static SettingsWrapper GetSample()
{
return new SettingsWrapper

View File

@ -0,0 +1,47 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using ASC.Core.Common.Settings;
namespace ASC.Web.Studio.Core
{
public class StudioAdminMessageSettings : ISettings
{
public bool Enable { get; set; }
public Guid ID
{
get { return new Guid("{28902650-58A9-11E1-B6A9-0F194924019B}"); }
}
public ISettings GetDefault(IServiceProvider serviceProvider)
{
return new StudioAdminMessageSettings { Enable = false };
}
}
}

View File

@ -0,0 +1,47 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using ASC.Core.Common.Settings;
namespace ASC.Web.Studio.Core
{
public class StudioTrustedDomainSettings : ISettings
{
public bool InviteUsersAsVisitors { get; set; }
public Guid ID
{
get { return new Guid("{00A2DB01-BAE3-48aa-BE32-CE768D7C874E}"); }
}
public ISettings GetDefault(IServiceProvider serviceProvider)
{
return new StudioTrustedDomainSettings { InviteUsersAsVisitors = false };
}
}
}