using Microsoft.AspNetCore.Http;
using Raven.Client.Documents;
using Raven.Client.Documents.Session;
using System.Threading.Tasks;
using zero.Core.Entities;
namespace zero.Core.Api
{
public class AuthenticationApi : IAuthenticationApi
{
protected IDocumentStore Raven { get; private set; }
protected IHttpContextAccessor HttpContextAccessor { get; set; }
public AuthenticationApi(IDocumentStore raven, IHttpContextAccessor httpContextAccessor)
{
Raven = raven;
HttpContextAccessor = httpContextAccessor;
}
///
public bool IsLoggedIn()
{
return HttpContextAccessor.HttpContext.User != null;
}
///
public string GetUserId()
{
return null;
//ResolveIdFromClaimsPrincipal(HttpContextAccessor.HttpContext.User);
}
///
public async Task GetUser()
{
await Task.Delay(0);
return null;
}
}
public interface IAuthenticationApi
{
///
/// Whether a user is currently logged-in
///
bool IsLoggedIn();
///
/// Get the ID of the currently logged in user
///
string GetUserId();
///
/// Get the currently logged-in user (or null if not logged in)
///
Task GetUser();
}
}