49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System.Net.Http.Json;
|
|
using TIAMWebApp.Shared.Application.Interfaces;
|
|
using TIAMWebApp.Shared.Application.Models;
|
|
|
|
namespace TIAMWebApp.Client.Services
|
|
{
|
|
public class UserDataService : IUserDataService
|
|
{
|
|
private readonly HttpClient http;
|
|
public User? User { get; set; } = new User();
|
|
|
|
public UserDataService(HttpClient http)
|
|
{
|
|
this.http = http;
|
|
}
|
|
|
|
public async Task<User> IsLoggedInAsync()
|
|
{
|
|
if (User == null)
|
|
{
|
|
User = new User();
|
|
User.IsLoggedIn = false;
|
|
User.UserType = UserType.User;
|
|
return User;
|
|
}
|
|
|
|
else
|
|
{
|
|
return User;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task<User> AuthorizeUserAsync(int userType)
|
|
{
|
|
if (User == null)
|
|
{
|
|
User = new User();
|
|
}
|
|
//simply return true for now
|
|
User.IsLoggedIn = true;
|
|
User.UserType = (UserType)userType;
|
|
return User;
|
|
}
|
|
|
|
}
|
|
}
|
|
|