Skip to content

Commit

Permalink
Updated to .NET Core 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neodescis committed May 11, 2018
1 parent 89f3243 commit 0b3e3f7
Show file tree
Hide file tree
Showing 17 changed files with 7,971 additions and 329 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ cd src/ReactBoilerplate
npm install
gulp
dotnet restore
# The following line is only for the 'master' branch, which has a database backend (user management).
# It is not needed when using 'empty-template'.
# The following two lines are only for the 'master' branch, which has a database backend (user management).
# They are not needed when using 'empty-template'.
dotnet ef migrations add initial
dotnet ef database update
dotnet run
```
Expand Down
13 changes: 6 additions & 7 deletions ReactBoilerplate.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C23ABA50-98BF-4132-B6F6-43605AD05B0F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BCDEFAE7-02D5-49F6-9054-511C7B472A27}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ReactBoilerplate", "src\ReactBoilerplate\ReactBoilerplate.xproj", "{A9424E07-13A1-49AF-BE65-EBCE6B4F343A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactBoilerplate", "src\ReactBoilerplate\ReactBoilerplate.csproj", "{A9424E07-13A1-49AF-BE65-EBCE6B4F343A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,4 +25,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{A9424E07-13A1-49AF-BE65-EBCE6B4F343A} = {C23ABA50-98BF-4132-B6F6-43605AD05B0F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ABA2BABF-36F7-43D0-9820-1BA0F96428C7}
EndGlobalSection
EndGlobal
3 changes: 0 additions & 3 deletions global.json

This file was deleted.

5 changes: 3 additions & 2 deletions src/ReactBoilerplate/Controllers/Account/ServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ public async Task<IActionResult> ExternalLoginCallback(bool autoLogin = true)
// unable to authenticate with an external login
return Content(callbackTemplate(data), "text/html");

var schemes = await _signInManager.GetExternalAuthenticationSchemesAsync();
if (string.IsNullOrEmpty(info.ProviderDisplayName))
{
info.ProviderDisplayName =
_signInManager.GetExternalAuthenticationSchemes()
.SingleOrDefault(x => x.AuthenticationScheme.Equals(info.LoginProvider))?
schemes
.SingleOrDefault(x => x.Name.Equals(info.LoginProvider))?
.DisplayName;
if (string.IsNullOrEmpty(info.ProviderDisplayName))
{
Expand Down
5 changes: 3 additions & 2 deletions src/ReactBoilerplate/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ protected async Task<GlobalState> BuildState()
state.Auth.LoggedIn = true;
}

var schemes = await _signInManager.GetExternalAuthenticationSchemesAsync();
state.ExternalLogin.LoginProviders
.AddRange(_signInManager.GetExternalAuthenticationSchemes()
.AddRange(schemes
.Select(x => new ExternalLoginState.ExternalLoginProvider
{
Scheme = x.AuthenticationScheme,
Scheme = x.Name,
DisplayName = x.DisplayName
}));

Expand Down
9 changes: 5 additions & 4 deletions src/ReactBoilerplate/Controllers/Manage/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,19 @@ private async Task<ExternalLoginsState> GetExternalLoginsState()
{
var user = await GetCurrentUserAsync();
var userLogins = await _userManager.GetLoginsAsync(user);
var schemes = await _signInManager.GetExternalAuthenticationSchemesAsync();
foreach (var userLogin in userLogins.Where(userLogin => string.IsNullOrEmpty(userLogin.ProviderDisplayName)))
{
userLogin.ProviderDisplayName =
_signInManager.GetExternalAuthenticationSchemes()
.SingleOrDefault(x => x.AuthenticationScheme.Equals(userLogin.LoginProvider))?
schemes
.SingleOrDefault(x => x.Name.Equals(userLogin.LoginProvider))?
.DisplayName;
if (string.IsNullOrEmpty(userLogin.ProviderDisplayName))
{
userLogin.ProviderDisplayName = userLogin.LoginProvider;
}
}
var otherLogins = _signInManager.GetExternalAuthenticationSchemes().Where(auth => userLogins.All(ul => auth.AuthenticationScheme != ul.LoginProvider)).ToList();
var otherLogins = schemes.Where(auth => userLogins.All(ul => auth.Name != ul.LoginProvider)).ToList();

return new ExternalLoginsState
{
Expand All @@ -253,7 +254,7 @@ private async Task<ExternalLoginsState> GetExternalLoginsState()
OtherLogins = otherLogins.Select(x => new ExternalLoginState.ExternalLoginProvider
{
DisplayName = x.DisplayName,
Scheme = x.AuthenticationScheme
Scheme = x.Name
}).ToList()
};
}
Expand Down
1 change: 1 addition & 0 deletions src/ReactBoilerplate/Models/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

namespace ReactBoilerplate.Models
Expand Down
26 changes: 6 additions & 20 deletions src/ReactBoilerplate/Program.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

namespace ReactBoilerplate
{
public class Program
{
private static readonly Dictionary<string, string> defaults =
new Dictionary<string, string> {
{ WebHostDefaults.EnvironmentKey, "development" }
};
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddInMemoryCollection(defaults)
.AddCommandLine(args)
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.Build();

var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}
24 changes: 17 additions & 7 deletions src/ReactBoilerplate/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15805/",
"applicationUrl": "http://localhost:15806/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"Development: IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"Hosting:Environment": "Development"
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"web": {
"commandName": "web",
"Development: .NET CLI": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"Hosting:Environment": "Development"
}
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:15806/"
},
"Production: Kestrel": {
"commandName": "Kestrel",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
},
"applicationUrl": "http://localhost:15806/"
}
}
}
31 changes: 31 additions & 0 deletions src/ReactBoilerplate/ReactBoilerplate.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>ReactBoilerplate</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>ReactBoilerplate</PackageId>
<UserSecretsId>89e1d495-c355-4990-bb58-6384b3b2e6df</UserSecretsId>
<AssetTargetFallback>$(AssetTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8</AssetTargetFallback>
</PropertyGroup>

<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="JavaScriptViewEngine.MvcCore1" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>

</Project>
27 changes: 0 additions & 27 deletions src/ReactBoilerplate/ReactBoilerplate.xproj

This file was deleted.

60 changes: 30 additions & 30 deletions src/ReactBoilerplate/Scripts/containers/Manage/Logins/Logins.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ class Logins extends Component {
<h4>Current logins</h4>
<table className="table">
<tbody>
{currentLogins.map((currentLogin, i) =>
(
<tr key={i}>
<td>
<Button onClick={this.removeButtonClick(currentLogin)}>
Remove
</Button>
{' '}
<ExternalLoginButton
key={i}
scheme={currentLogin.loginProvider}
text={currentLogin.loginProviderDisplayName} />
</td>
</tr>
))}
{currentLogins.map((currentLogin, i) =>
(
<tr key={i}>
<td>
<Button onClick={this.removeButtonClick(currentLogin)}>
Remove
</Button>
{' '}
<ExternalLoginButton
key={i}
scheme={currentLogin.loginProvider}
text={currentLogin.loginProviderDisplayName} />
</td>
</tr>
))}
</tbody>
</table>
</div>
Expand All @@ -84,21 +84,21 @@ class Logins extends Component {
<h4>Add another service to log in.</h4>
<table className="table">
<tbody>
{otherLogins.map((otherLogin, i) =>
(
<tr key={i}>
<td>
<Button onClick={this.addButtonClick(otherLogin.scheme)}>
Add
</Button>
{' '}
<ExternalLoginButton
key={i}
scheme={otherLogin.scheme}
text={otherLogin.displayName} />
</td>
</tr>
))}
{otherLogins.map((otherLogin, i) =>
(
<tr key={i}>
<td>
<Button onClick={this.addButtonClick(otherLogin.scheme)}>
Add
</Button>
{' '}
<ExternalLoginButton
key={i}
scheme={otherLogin.scheme}
text={otherLogin.displayName} />
</td>
</tr>
))}
</tbody>
</table>
</div>
Expand Down
Loading

0 comments on commit 0b3e3f7

Please sign in to comment.