Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronSadlerUK committed Jul 3, 2023
2 parents a3e11f4 + 95a9005 commit 3439c14
Show file tree
Hide file tree
Showing 154 changed files with 5,775 additions and 7 deletions.
38 changes: 38 additions & 0 deletions TestSiteV10/Controllers/LogoutSurfaceController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Cms.Web.Website.Controllers;

namespace TestSiteV10.Controllers
{
public class LogoutSurfaceController : SurfaceController
{
private readonly IMemberManager _memberManager;
private readonly IMemberSignInManager _memberSignInManager;

[HttpGet]
public async Task<IActionResult> Logout()
{
if (_memberManager.IsLoggedIn())
{
TempData.Clear();
await _memberSignInManager.SignOutAsync();
return RedirectToCurrentUmbracoPage();
}

return Redirect("/");
}

public LogoutSurfaceController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IMemberManager memberManager, IMemberSignInManager memberSignInManager) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
{
_memberManager = memberManager;
_memberSignInManager = memberSignInManager;
}
}
}
1 change: 1 addition & 0 deletions TestSiteV10/TestSiteV10.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<PackageReference Include="Umbraco.TheStarterKit" Version="10.0.0" />
<PackageReference Include="uSync" Version="10.6.1" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
</ItemGroup>

Expand Down
36 changes: 36 additions & 0 deletions TestSiteV10/Views/ContentPageLoggedIn.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Security
@using Umbraco.Cms.Web.Website.Controllers
@using TestSiteV10.Controllers
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.ContentPage>
@inject IMemberManager MemberManager;
@{
Layout = "master.cshtml";
var currentMember = await MemberManager.GetCurrentMemberAsync();
}

@Html.Partial("~/Views/Partials/SectionHeader.cshtml")

<section class="section">

<div class="container">
<div class="row">
<div class="col">
<h2>Is Logged In: @MemberManager.IsLoggedIn()</h2>
</div>
</div>
<div class="col-md-3">
<nav class="nav-bar nav-bar--list">
@Html.Partial("~/Views/Partials/Navigation/SubNavigation.cshtml")
</nav>
</div>

<div class="col-md-9">
<article>
@Html.GetGridHtml(Model, "bodyText", "bootstrap3-fluid")
</article>
</div>
</div>

</section>
118 changes: 118 additions & 0 deletions TestSiteV10/Views/MacroPartials/Login.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage


@using Umbraco.Cms.Web.Common.Models
@using Umbraco.Cms.Web.Common.Security
@using Umbraco.Cms.Web.Website.Controllers
@using Umbraco.Cms.Core.Services
@using Umbraco.Extensions
@using Umbraco.Cms.Core.Security
@using TestSiteV10.Controllers
@using Smidge.TagHelpers
@using Microsoft.AspNetCore.Mvc.TagHelpers
@inject IMemberExternalLoginProviders memberExternalLoginProviders
@inject ITwoFactorLoginService twoFactorLoginService
@inject IMemberManager MemberManager;
@{
var loginModel = new LoginModel();
// You can modify this to redirect to a different URL instead of the current one
loginModel.RedirectUrl = null;
var currentMember = await MemberManager.GetCurrentMemberAsync();
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/3.2.11/jquery.validate.unobtrusive.min.js"></script>

@if (@MemberManager.IsLoggedIn())
{
<p><a href="@(Url.SurfaceAction(nameof(LogoutSurfaceController.Logout), "LogoutSurface"))" class="crumina-button button--primary button--l w-100">Logout</a></p>
}

else if (ViewData.TryGetTwoFactorProviderNames(out var providerNames))
{

foreach (var providerName in providerNames)
{
<div class="2fa-form">
<h4>Two factor with @providerName.</h4>
<div asp-validation-summary="All" class="text-danger"></div>
@using (Html.BeginUmbracoForm<UmbTwoFactorLoginController>(nameof(UmbTwoFactorLoginController.Verify2FACode)))
{

<text>
<input type="hidden" name="provider" value="@providerName"/>
Input security code: <input name="code" value=""/><br/>
<button type="submit" class="btn btn-primary">Validate</button>
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
</text>
}
</div>
}

}
else
{


<div class="login-form">

@using (Html.BeginUmbracoForm<UmbLoginController>(
"HandleLogin", new { RedirectUrl = loginModel.RedirectUrl })) {

<h4>Log in with a local account.</h4>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="mb-3">
<label asp-for="@loginModel.Username" class="form-label"></label>
<input asp-for="@loginModel.Username" class="form-control" />
<span asp-validation-for="@loginModel.Username" class="form-text text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="@loginModel.Password" class="form-label"></label>
<input asp-for="@loginModel.Password" class="form-control" />
<span asp-validation-for="@loginModel.Password" class="form-text text-danger"></span>
</div>
<div class="mb-3 form-check">
<input asp-for="@loginModel.RememberMe" class="form-check-input">
<label asp-for="@loginModel.RememberMe" class="form-check-label">
@Html.DisplayNameFor(m => loginModel.RememberMe)
</label>
</div>

<button type="submit" class="btn btn-primary">Log in</button>


}
@{
var loginProviders = await memberExternalLoginProviders.GetMemberProvidersAsync();
var externalSignInError = ViewData.GetExternalSignInProviderErrors();

if (loginProviders.Any())
{
<hr/>
<h4>Or using external providers</h4>
if (externalSignInError?.AuthenticationType is null && externalSignInError?.Errors.Any() == true)
{
@Html.DisplayFor(x => externalSignInError.Errors);
}

@foreach (var login in await memberExternalLoginProviders.GetMemberProvidersAsync())
{

@using (Html.BeginUmbracoForm<UmbExternalLoginController>(nameof(UmbExternalLoginController.ExternalLogin)))
{
<button type="submit" name="provider" value="@login.ExternalLoginProvider.AuthenticationType">
Sign in with @login.AuthenticationScheme.DisplayName
</button>

if (externalSignInError?.AuthenticationType == login.ExternalLoginProvider.AuthenticationType)
{
@Html.DisplayFor(x => externalSignInError.Errors);
}
}
}
}
}
</div>
}
40 changes: 40 additions & 0 deletions TestSiteV10/uSync/v9/Content/about-this-starter-kit.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Content Key="ee82cba3-a0e7-4063-9ae1-3026a4f72a3d" Alias="About this Starter Kit" Level="3">
<Info>
<Parent Key="3cce2545-e3ac-44ec-bf55-a52cc5965db3">About Us</Parent>
<Path>/Home/AboutUs/AboutThisStarterKit</Path>
<Trashed>false</Trashed>
<ContentType>contentPage</ContentType>
<CreateDate>2022-06-16T23:11:36</CreateDate>
<NodeName Default="About this Starter Kit" />
<SortOrder>0</SortOrder>
<Published Default="true" />
<Schedule />
<Template Key="36b90024-6944-4edb-9226-8ac1da594bf1">contentPage</Template>
</Info>
<Properties>
<bodyText>
<Value><![CDATA[{
"name": "1 column layout",
"sections": [
{
"grid": "12",
"rows": []
}
]
}]]></Value>
</bodyText>
<keywords>
<Value><![CDATA[[]]]></Value>
</keywords>
<pageTitle>
<Value><![CDATA[About this Starter Kit]]></Value>
</pageTitle>
<seoMetaDescription>
<Value><![CDATA[]]></Value>
</seoMetaDescription>
<umbracoNavihide>
<Value><![CDATA[0]]></Value>
</umbracoNavihide>
</Properties>
</Content>
122 changes: 122 additions & 0 deletions TestSiteV10/uSync/v9/Content/about-us.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Content Key="3cce2545-e3ac-44ec-bf55-a52cc5965db3" Alias="About Us" Level="2">
<Info>
<Parent Key="ca4249ed-2b23-4337-b522-63cabe5587d1">Home</Parent>
<Path>/Home/AboutUs</Path>
<Trashed>false</Trashed>
<ContentType>contentPage</ContentType>
<CreateDate>2022-06-16T23:11:36</CreateDate>
<NodeName Default="About Us" />
<SortOrder>2</SortOrder>
<Published Default="true" />
<Schedule />
<Template Key="36b90024-6944-4edb-9226-8ac1da594bf1">contentPage</Template>
</Info>
<Properties>
<bodyText>
<Value><![CDATA[{
"name": "1 column layout",
"sections": [
{
"grid": "12",
"rows": [
{
"name": "FullWidth",
"id": "f10995f1-918d-3e50-e50d-8c41bbe297ce",
"areas": [
{
"grid": "12",
"controls": [
{
"value": "Oooh la la",
"editor": {
"alias": "headline",
"view": "textstring"
},
"styles": null,
"config": null
}
],
"styles": null,
"config": null
}
],
"styles": null,
"config": null
},
{
"name": "Article",
"id": "4d6e2221-e2d9-95bc-8ceb-624bc8df8e3f",
"areas": [
{
"grid": "4",
"controls": [
{
"value": {
"focalPoint": {
"left": 0.5,
"top": 0.5
},
"id": 1144,
"udi": "umb://media/97f2b01ace574718a18c3404fb8e25e4",
"image": "/media/dsypff0x/laura_weatherhead.jpg"
},
"editor": {
"alias": "media",
"view": "media"
},
"styles": null,
"config": null
}
],
"styles": null,
"config": null
},
{
"grid": "8",
"controls": [
{
"value": "<p>Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur aliquet quam id dui posuere blandit. Vivamus suscipit tortor eget felis porttitor volutpat. Proin eget tortor risus. Sed porttitor lectus nibh. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Pellentesque in ipsum id orci porta dapibus. Nulla porttitor accumsan tincidunt. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a.</p>\n<p>Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur aliquet quam id dui posuere blandit. Vivamus suscipit tortor eget felis porttitor volutpat. Proin eget tortor risus. Sed porttitor lectus nibh. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Pellentesque in ipsum id orci porta dapibus. Nulla porttitor accumsan tincidunt. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a.</p>",
"editor": {
"alias": "rte",
"view": "rte"
},
"styles": null,
"config": null
},
{
"value": "<iframe width=\"360\" height=\"203\" src=\"https://www.youtube.com/embed/HPgKSCp_Y_U?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>",
"editor": {
"alias": "embed",
"view": "embed"
},
"styles": null,
"config": null
}
],
"styles": null,
"config": null
}
],
"styles": null,
"config": null
}
]
}
]
}]]></Value>
</bodyText>
<keywords>
<Value><![CDATA[[]]]></Value>
</keywords>
<pageTitle>
<Value><![CDATA[About Us]]></Value>
</pageTitle>
<seoMetaDescription>
<Value><![CDATA[]]></Value>
</seoMetaDescription>
<umbracoNavihide>
<Value><![CDATA[0]]></Value>
</umbracoNavihide>
</Properties>
</Content>
Loading

0 comments on commit 3439c14

Please sign in to comment.