Skip to content

Commit c53e808

Browse files
authored
Merge pull request #10 from umbraco/feature/zapier-integration
Update user group configuration
2 parents cc37d85 + b6e1944 commit c53e808

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using System.Configuration;
2+
using System.Linq;
23
using System.Web.Http;
34

45
using Umbraco.Core.Services;
@@ -9,17 +10,25 @@ namespace Umbraco.Forms.Integrations.Automation.Zapier.Controllers
910
{
1011
public class AuthController : UmbracoApiController
1112
{
13+
private const string UmbracoCmsIntegrationsAutomationZapierUserGroup = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroup";
14+
1215
[HttpPost]
1316
public bool ValidateUser([FromBody] UserModel userModel)
1417
{
1518
var isUserValid = Security.ValidateBackOfficeCredentials(userModel.Username, userModel.Password);
1619
if (!isUserValid) return false;
1720

18-
IUserService userService = Services.UserService;
21+
var userGroup = ConfigurationManager.AppSettings[UmbracoCmsIntegrationsAutomationZapierUserGroup];
22+
if (!string.IsNullOrEmpty(userGroup))
23+
{
24+
IUserService userService = Services.UserService;
25+
26+
var user = userService.GetByUsername(userModel.Username);
1927

20-
var user = userService.GetByUsername(userModel.Username);
28+
return user != null && user.Groups.Any(p => p.Name == userGroup);
29+
}
2130

22-
return user != null && user.Groups.Any(p => p.Name == userModel.UserGroup);
31+
return true;
2332
}
2433
}
2534
}

src/Umbraco.Forms.Integrations.Automation.Zapier/Models/UserModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ public class UserModel
66
public string Username { get; set; }
77

88
public string Password { get; set; }
9-
10-
public string UserGroup { get; set; }
119
}
1210
}

src/Umbraco.Forms.Integrations.Automation.Zapier/ZapierWorkflow.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ namespace Umbraco.Forms.Integrations.Automation.Zapier
1414
{
1515
public class ZapierWorkflow : WorkflowType
1616
{
17-
private const string UserGroup = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroup";
18-
1917
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
2018

2119
public ZapierWorkflow(IUmbracoContextAccessor umbracoContextAccessor)
@@ -79,9 +77,6 @@ public override List<Exception> ValidateSettings()
7977
var validator = new WebHookValidator();
8078
validator.IsValid(WebHookUri, ref exceptions);
8179

82-
if(string.IsNullOrEmpty(ConfigurationManager.AppSettings[UserGroup]))
83-
exceptions.Add(new Exception("User group setting is required."));
84-
8580
return exceptions;
8681
}
8782

0 commit comments

Comments
 (0)