File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
src/Umbraco.Forms.Integrations.Automation.Zapier Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 1
- using System . Linq ;
1
+ using System . Configuration ;
2
+ using System . Linq ;
2
3
using System . Web . Http ;
3
4
4
5
using Umbraco . Core . Services ;
@@ -9,17 +10,25 @@ namespace Umbraco.Forms.Integrations.Automation.Zapier.Controllers
9
10
{
10
11
public class AuthController : UmbracoApiController
11
12
{
13
+ private const string UmbracoCmsIntegrationsAutomationZapierUserGroup = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroup" ;
14
+
12
15
[ HttpPost ]
13
16
public bool ValidateUser ( [ FromBody ] UserModel userModel )
14
17
{
15
18
var isUserValid = Security . ValidateBackOfficeCredentials ( userModel . Username , userModel . Password ) ;
16
19
if ( ! isUserValid ) return false ;
17
20
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 ) ;
19
27
20
- var user = userService . GetByUsername ( userModel . Username ) ;
28
+ return user != null && user . Groups . Any ( p => p . Name == userGroup ) ;
29
+ }
21
30
22
- return user != null && user . Groups . Any ( p => p . Name == userModel . UserGroup ) ;
31
+ return true ;
23
32
}
24
33
}
25
34
}
Original file line number Diff line number Diff line change @@ -6,7 +6,5 @@ public class UserModel
6
6
public string Username { get ; set ; }
7
7
8
8
public string Password { get ; set ; }
9
-
10
- public string UserGroup { get ; set ; }
11
9
}
12
10
}
Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ namespace Umbraco.Forms.Integrations.Automation.Zapier
14
14
{
15
15
public class ZapierWorkflow : WorkflowType
16
16
{
17
- private const string UserGroup = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroup" ;
18
-
19
17
private readonly IUmbracoContextAccessor _umbracoContextAccessor ;
20
18
21
19
public ZapierWorkflow ( IUmbracoContextAccessor umbracoContextAccessor )
@@ -79,9 +77,6 @@ public override List<Exception> ValidateSettings()
79
77
var validator = new WebHookValidator ( ) ;
80
78
validator . IsValid ( WebHookUri , ref exceptions ) ;
81
79
82
- if ( string . IsNullOrEmpty ( ConfigurationManager . AppSettings [ UserGroup ] ) )
83
- exceptions . Add ( new Exception ( "User group setting is required." ) ) ;
84
-
85
80
return exceptions ;
86
81
}
87
82
You can’t perform that action at this time.
0 commit comments