Skip to content

Commit

Permalink
Fixup httpcontext and renamed project.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacneil committed Jan 3, 2018
1 parent 955cd92 commit 86913b3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/WebApi/bin/Debug/netcoreapp2.0/WebApi.dll",
"program": "${workspaceFolder}/src/bin/Debug/netcoreapp2.0/AngularASPNETCore2WebApiAuth.dll",
"args": [],
"cwd": "${workspaceFolder}/WebApi",
"cwd": "${workspaceFolder}/src",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/WebApi/WebApi.csproj"
"${workspaceFolder}/src/AngularASPNETCore2WebApiAuth.csproj"
],
"problemMatcher": "$msCompile"
}
Expand Down
8 changes: 5 additions & 3 deletions src/Controllers/DashboardController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@


using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using AngularASPNETCore2WebApiAuth.Data;
using AngularASPNETCore2WebApiAuth.Models.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
Expand All @@ -19,9 +20,9 @@ public class DashboardController : Controller
private readonly ClaimsPrincipal _caller;
private readonly ApplicationDbContext _appDbContext;

public DashboardController(ClaimsPrincipal caller, UserManager<AppUser> userManager, ApplicationDbContext appDbContext)
public DashboardController(UserManager<AppUser> userManager, ApplicationDbContext appDbContext, IHttpContextAccessor httpContextAccessor)
{
_caller = caller;
_caller = httpContextAccessor.HttpContext.User;
_appDbContext = appDbContext;
}

Expand All @@ -30,6 +31,7 @@ public DashboardController(ClaimsPrincipal caller, UserManager<AppUser> userMana
public async Task<IActionResult> Home()
{
// retrieve the user info
//HttpContext.User
var userId = _caller.Claims.Single(c => c.Type == "id");
var customer = await _appDbContext.Customers.Include(c => c.Identity).SingleAsync(c => c.Identity.Id == userId.Value);

Expand Down
27 changes: 0 additions & 27 deletions src/README.md

This file was deleted.

3 changes: 2 additions & 1 deletion src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Tokens;


Expand Down Expand Up @@ -50,7 +51,7 @@ public void ConfigureServices(IServiceCollection services)
// Register the ConfigurationBuilder instance of FacebookAuthSettings
services.Configure<FacebookAuthSettings>(Configuration.GetSection(nameof(FacebookAuthSettings)));

services.AddTransient(s => s.GetService<IHttpContextAccessor>().HttpContext.User);
services.TryAddTransient<IHttpContextAccessor, HttpContextAccessor>();

// jwt wire up
// Get options from app settings
Expand Down

0 comments on commit 86913b3

Please sign in to comment.