File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
src/Umbraco.Cms.Integrations.Automation.Zapier Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Configuration ;
2
+ using System . Linq ;
3
+ using System . Web . Http ;
4
+
5
+ using Umbraco . Cms . Integrations . Automation . Zapier . Models ;
6
+ using Umbraco . Core . Services ;
7
+ using Umbraco . Web . WebApi ;
8
+
9
+ namespace Umbraco . Cms . Integrations . Automation . Zapier . Controllers
10
+ {
11
+ public class AuthController : UmbracoApiController
12
+ {
13
+ private const string UmbracoCmsIntegrationsAutomationZapierUserGroup = "Umbraco.Cms.Integrations.Automation.Zapier.UserGroup" ;
14
+
15
+ [ HttpPost ]
16
+ public bool ValidateUser ( [ FromBody ] UserModel userModel )
17
+ {
18
+ var isUserValid = Security . ValidateBackOfficeCredentials ( userModel . Username , userModel . Password ) ;
19
+ if ( ! isUserValid ) return false ;
20
+
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 ) ;
27
+
28
+ var isValid = user != null && user . Groups . Any ( p => p . Name == userGroup ) ;
29
+
30
+ return isValid ;
31
+ }
32
+
33
+ return true ;
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+
2
+ namespace Umbraco . Cms . Integrations . Automation . Zapier . Models
3
+ {
4
+ public class UserModel
5
+ {
6
+ public string Username { get ; set ; }
7
+
8
+ public string Password { get ; set ; }
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments