-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from Kentico/kentico-13
Add support for Kentico 13
- Loading branch information
Showing
205 changed files
with
23,270 additions
and
10,973 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
# See https://help.github.com/articles/about-code-owners/ | ||
|
||
* @JosefDvorak | ||
* @kentico-ericd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Autofac; | ||
|
||
using KenticoInspector.Core.Modules; | ||
|
||
using System.Reflection; | ||
|
||
namespace KenticoInspector.Reports | ||
{ | ||
public class ActionsModule : Autofac.Module | ||
{ | ||
protected override void Load(ContainerBuilder builder) | ||
{ | ||
var assemblies = Assembly.GetExecutingAssembly(); | ||
builder.RegisterAssemblyTypes(assemblies) | ||
.Where(t => t.IsClass | ||
&& !t.IsAbstract | ||
&& typeof(IAction).IsAssignableFrom(t) | ||
) | ||
.AsImplementedInterfaces() | ||
.InstancePerLifetimeScope(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Autofac" Version="4.9.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\KenticoInspector.Core\KenticoInspector.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="ResetCmsUserLogin\Metadata\en-US.yaml"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ResetCmsUserLogin\Scripts\GetAdministrators.sql"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ResetCmsUserLogin\Scripts\ResetAndEnableUser.sql"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using KenticoInspector.Actions.ResetCmsUserLogin.Models; | ||
using KenticoInspector.Core; | ||
using KenticoInspector.Core.Constants; | ||
using KenticoInspector.Core.Helpers; | ||
using KenticoInspector.Core.Models; | ||
using KenticoInspector.Core.Services.Interfaces; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace KenticoInspector.Actions.ResetCmsUserLogin | ||
{ | ||
public class Action : AbstractAction<Terms,Options> | ||
{ | ||
private IDatabaseService databaseService; | ||
|
||
public override IList<Version> CompatibleVersions => VersionHelper.GetVersionList("10", "11", "12", "13"); | ||
|
||
public override IList<string> Tags => new List<string> { | ||
ActionTags.Reset, | ||
ActionTags.User | ||
}; | ||
|
||
public Action(IDatabaseService databaseService, IModuleMetadataService moduleMetadataService) : base(moduleMetadataService) | ||
{ | ||
this.databaseService = databaseService; | ||
} | ||
|
||
public override ActionResults Execute(Options options) | ||
{ | ||
if (options.UserId < 0) | ||
{ | ||
return GetInvalidOptionsResult(); | ||
} | ||
|
||
// No user provided, list users | ||
if (options.UserId == 0) | ||
{ | ||
return GetListingResult(); | ||
} | ||
|
||
// Reset provided user | ||
databaseService.ExecuteSqlFromFileGeneric(Scripts.ResetAndEnableUser, new { UserID = options.UserId }); | ||
var result = GetListingResult(); | ||
result.Summary = Metadata.Terms.UserReset.With(new { | ||
userId = options.UserId | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
public override ActionResults GetInvalidOptionsResult() | ||
{ | ||
return new ActionResults { | ||
Status = ResultsStatus.Error, | ||
Summary = Metadata.Terms.InvalidOptions | ||
}; | ||
} | ||
|
||
private ActionResults GetListingResult() | ||
{ | ||
var administratorUsers = databaseService.ExecuteSqlFromFile<CmsUser>(Scripts.GetAdministrators); | ||
var data = new TableResult<CmsUser>() | ||
{ | ||
Name = Metadata.Terms.TableTitle, | ||
Rows = administratorUsers | ||
}; | ||
|
||
return new ActionResults | ||
{ | ||
Type = ResultsType.Table, | ||
Status = ResultsStatus.Information, | ||
Summary = Metadata.Terms.ListSummary, | ||
Data = data | ||
}; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
KenticoInspector.Actions/ResetCmsUserLogin/Metadata/en-US.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
details: | ||
name: Global Administrator Summary | ||
shortDescription: Reset a global administrator so that you can login with an empty password. | ||
longDescription: | | ||
This action ensures that the global administrator user is enabled, their password is blank, and their last changed date is reset to today. | ||
Run the action without options to view the global administrator accounts. To reset a user account, re-run the action with their user ID below. | ||
terms: | ||
tableTitle: Global administrators | ||
invalidOptions: The user ID must be an integer greater than zero. | ||
listSummary: Set the user ID you wish to reset and re-run | ||
userReset: User ID <userId> was reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace KenticoInspector.Actions.ResetCmsUserLogin.Models | ||
{ | ||
public class Options | ||
{ | ||
public int UserId { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
KenticoInspector.Actions/ResetCmsUserLogin/Models/Results/CmsUser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace KenticoInspector.Actions.ResetCmsUserLogin.Models | ||
{ | ||
public class CmsUser | ||
{ | ||
public int UserID { get; set; } | ||
|
||
public string UserName { get; set; } | ||
|
||
public string Password { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
KenticoInspector.Actions/ResetCmsUserLogin/Models/Terms.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using KenticoInspector.Core.Models; | ||
|
||
namespace KenticoInspector.Actions.ResetCmsUserLogin.Models | ||
{ | ||
public class Terms | ||
{ | ||
public Term InvalidOptions { get; internal set; } | ||
|
||
public Term TableTitle { get; internal set; } | ||
|
||
public Term ListSummary { get; internal set; } | ||
|
||
public Term UserReset { get; internal set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace KenticoInspector.Actions.ResetCmsUserLogin | ||
{ | ||
public static class Scripts | ||
{ | ||
public static string BaseDirectory = $"{nameof(ResetCmsUserLogin)}/Scripts"; | ||
|
||
public static string GetAdministrators => $"{BaseDirectory}/{nameof(GetAdministrators)}.sql"; | ||
|
||
public static string ResetAndEnableUser => $"{BaseDirectory}/{nameof(ResetAndEnableUser)}.sql"; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
KenticoInspector.Actions/ResetCmsUserLogin/Scripts/GetAdministrators.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SELECT UserID, UserName, UserPassword AS 'Password', UserEnabled AS 'Enabled' FROM CMS_User WHERE UserPrivilegeLevel = 3 |
7 changes: 7 additions & 0 deletions
7
KenticoInspector.Actions/ResetCmsUserLogin/Scripts/ResetAndEnableUser.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
UPDATE CMS_User | ||
SET UserPassword = '', UserEnabled = 1 | ||
WHERE UserID = @UserID | ||
|
||
UPDATE CMS_UserSettings | ||
SET UserPasswordLastChanged = GETDATE() | ||
WHERE UserSettingsUserID = @UserID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project> | ||
<ItemGroup Label="StaticCodeAnalysis"> | ||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.41.0.50478"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.