Auth DB schema migration, ef design, auth
This commit is contained in:
parent
a0d5df1c52
commit
5e4bfaa95e
22 changed files with 1106 additions and 38 deletions
32
src/Interlinked.Core/Services/UserManager.cs
Normal file
32
src/Interlinked.Core/Services/UserManager.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Interlinked.Shared.Model;
|
||||
|
||||
namespace Interlinked.Core.Services;
|
||||
|
||||
public class UserManager
|
||||
{
|
||||
public UserManager(IServiceProvider serv)
|
||||
{
|
||||
_serv = serv;
|
||||
}
|
||||
|
||||
private readonly IServiceProvider _serv;
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
using var scope = _serv.CreateAsyncScope();
|
||||
var resp = await scope.ServiceProvider.GetRequiredService<HttpClient>().GetAsync("/api/auth/userdata");
|
||||
if (resp.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
User = (await resp.Content.ReadFromJsonAsync<UserModel>())!;
|
||||
}
|
||||
}
|
||||
|
||||
public UserModel User { get; set; } = default!;
|
||||
public bool IsAuthorized => User != null;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue