Skip to content

Commit

Permalink
tweak proj references, add login to lorem
Browse files Browse the repository at this point in the history
backport dictionary helper from core
  • Loading branch information
ninianne98 committed Jul 17, 2023
1 parent 4082486 commit e538718
Show file tree
Hide file tree
Showing 26 changed files with 423 additions and 150 deletions.
2 changes: 1 addition & 1 deletion CMSAdmin/Controllers/CmsAdminController.cs
Expand Up @@ -2956,7 +2956,7 @@ where aw.PlaceholderName.ToLowerInvariant() == model.PlaceholderName.ToLowerInva
}

protected void SignOut() {
securityHelper.AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
securityHelper.LogoutSession();
Session.Clear();
}

Expand Down
16 changes: 8 additions & 8 deletions CMSAdmin/Web.config
Expand Up @@ -115,35 +115,35 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
<bindingRedirect oldVersion="0.0.0.0-3.7.0.0" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
<bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
Expand Down
12 changes: 0 additions & 12 deletions CMSComponents/CMSComponents.csproj
Expand Up @@ -32,10 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -103,10 +99,6 @@
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
<Private>True</Private>
Expand All @@ -128,10 +120,6 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdvContentModel.cs" />
Expand Down
3 changes: 0 additions & 3 deletions CMSComponents/packages.config
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" targetFramework="net45" />
Expand All @@ -17,5 +15,4 @@
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
12 changes: 0 additions & 12 deletions CMSCore/CMSCore.csproj
Expand Up @@ -58,10 +58,6 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -137,10 +133,6 @@
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
<Private>True</Private>
Expand All @@ -165,10 +157,6 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CannedQueries.cs" />
Expand Down
3 changes: 0 additions & 3 deletions CMSCore/packages.config
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" targetFramework="net45" />
Expand All @@ -17,5 +15,4 @@
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
12 changes: 0 additions & 12 deletions CMSInterfaces/CMSInterfaces.csproj
Expand Up @@ -55,10 +55,6 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.Infrastructure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
Expand All @@ -82,10 +78,6 @@
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
<Private>True</Private>
Expand All @@ -110,10 +102,6 @@
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdminModuleData.cs" />
Expand Down
8 changes: 4 additions & 4 deletions CMSInterfaces/ParmParser.cs
Expand Up @@ -17,7 +17,7 @@ namespace Carrotware.CMS.Interface {

public static class ParmParser {

public static string GetParmValue(Dictionary<string, string> parmDictionary, string sKey) {
public static string GetParmValue(this Dictionary<string, string> parmDictionary, string sKey) {
string ret = null;

if (parmDictionary.Any()) {
Expand All @@ -29,7 +29,7 @@ where c.Key.ToLowerInvariant() == sKey.ToLowerInvariant()
return ret;
}

public static string GetParmValue(Dictionary<string, string> parmDictionary, string sKey, string sDefault) {
public static string GetParmValue(this Dictionary<string, string> parmDictionary, string sKey, string sDefault) {
string ret = null;

if (parmDictionary.Any()) {
Expand All @@ -43,15 +43,15 @@ where c.Key.ToLowerInvariant() == sKey.ToLowerInvariant()
return ret;
}

public static string GetParmValueDefaultEmpty(Dictionary<string, string> parmDictionary, string sKey, string sDefault) {
public static string GetParmValueDefaultEmpty(this Dictionary<string, string> parmDictionary, string sKey, string sDefault) {
string ret = GetParmValue(parmDictionary, sKey, sDefault);

ret = String.IsNullOrEmpty(ret) ? sDefault : ret;

return ret;
}

public static List<string> GetParmValueList(Dictionary<string, string> parmDictionary, string sKey) {
public static List<string> GetParmValueList(this Dictionary<string, string> parmDictionary, string sKey) {
sKey = sKey.EndsWith("|") ? sKey : sKey + "|";
sKey = sKey.ToLowerInvariant();

Expand Down
15 changes: 9 additions & 6 deletions CMSInterfaces/RenderWidgetHelper.cs
Expand Up @@ -33,17 +33,20 @@ public static class RenderWidgetHelper {
var type = controller.GetType();
var routeData = new RouteData();

var wrapper = new HttpContextWrapper(System.Web.HttpContext.Current);
var wrapper = new HttpContextWrapper(HttpContext.Current);
string controlerName = controller.GetType().Name.ToLowerInvariant().Replace("controller", string.Empty);

routeData.Values["area"] = string.Empty;
if (!string.IsNullOrWhiteSpace(areaName)) {
routeData.Values.Add("area", areaName);
routeData.Values["area"] = areaName;
}
routeData.Values.Add("action", actionName);
routeData.Values.Add("controller", controlerName);

foreach (var r in source.RouteData.Values.Where(x => x.Key.ToLowerInvariant() != "controller" && x.Key.ToLowerInvariant() != "action")) {
routeData.Values.Add(r.Key, r.Value);
routeData.Values["action"] = actionName;
routeData.Values["controller"] = controlerName;

foreach (var r in source.RouteData.Values.Where(x => x.Key.ToLowerInvariant() != "controller"
&& x.Key.ToLowerInvariant() != "action" && x.Key.ToLowerInvariant() != "area")) {
routeData.Values[r.Key] = r.Value;
}

var context = new ControllerContext(wrapper, routeData, controller);
Expand Down
3 changes: 0 additions & 3 deletions CMSInterfaces/packages.config
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
12 changes: 0 additions & 12 deletions CMSSecurity/CMSSecurity.csproj
Expand Up @@ -32,10 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -101,10 +97,6 @@
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
<Private>True</Private>
Expand All @@ -123,10 +115,6 @@
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AccountViewModels.cs" />
Expand Down
23 changes: 22 additions & 1 deletion CMSSecurity/SecurityHelper.cs
@@ -1,7 +1,9 @@
using Carrotware.CMS.Security.Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using System;
using System.Threading.Tasks;
using System.Web;

/*
Expand Down Expand Up @@ -86,7 +88,26 @@ public SecurityHelper(SecurityDbContext db)
}
}

//public DataProtectorTokenProvider<ApplicationUser> UserToken { get; set; }
public void LogoutSession() {
this.AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
HttpContext.Current.Session.Clear();
}

public async Task<ApplicationUser> FindByNameAsync(string userName) {
return await this.UserManager.FindByNameAsync(userName);
}

public async Task<bool> SimpleLogInAsync(string userName, string password, bool rememberMe) {
var user = await this.UserManager.FindByNameAsync(userName);

if (user == null) {
return false;
}

var result = await this.SignInManager.PasswordSignInAsync(userName, password, rememberMe, shouldLockout: true);

return result == Microsoft.AspNet.Identity.Owin.SignInStatus.Success;
}

public void Dispose() {
if (_userManager != null) {
Expand Down
3 changes: 0 additions & 3 deletions CMSSecurity/packages.config
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.4" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.9" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" targetFramework="net45" />
Expand All @@ -17,5 +15,4 @@
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>

0 comments on commit e538718

Please sign in to comment.