Outline

Demo: Implement GetLoggedInUser

In the Conduit.Repositories Project, modify AccountRepository.cs file, add the following code to the body of the method:

return await Context
    .Accounts
    .Where(u => u.Email == HttpContextAccessor.HttpContext.User.Identity.Name)
    .Include(p => p.Person)
    .FirstOrDefaultAsync();

Modify the CreateUser method and add the following code:

if (HttpContextAccessor.HttpContext.Request.Headers.ContainsKey("Authorization"))
{
    user.Token = HttpContextAccessor
                    .HttpContext
                    .Request
                    .Headers["Authorization"]
                    .ToString()
                    .Split(" ")[1];
}

In the next demo we'll try our newly functional api endpoint.

 

I finished! On to the next chapter