public interface IAuthenticationService
{
Task<TurnaResponse> RegisterUser(User user);
Task<TurnaResponse> LoginUser(string email, string password);
Task<TurnaResponse> ResetPassword(string userId, string password);
Task<TurnaResponse> ForgotPassword(string email);
Task<TurnaResponse> ProcessSession(string userId);
bool IsUserAuthenticated();
}
public async Task<TurnaResponse> ProcessSession(string userId)
{
UriBuilder builder = new UriBuilder(ApiConstants.BaseApiUrl)
{
Path = ApiConstants.ProcessSessionEndpoint
};
var query = System.Web.HttpUtility.ParseQueryString(builder.Query);
query["userId"] = userId;
builder.Query = query.ToString();
var result = await _genericRepository.GetAsync<TurnaResponse>(builder.ToString(), "");
result.Data = result.Data != null
? JsonConvert.DeserializeObject<User>(result.Data.ToString()) : result.Data;
_sessionResponse = (TurnaResponse)result;
return result;
}
How can I call the ProcessSession method below to get the response object in IsAuthenticated method that returns boolean ?
public bool IsUserAuthenticated()
{
var result = !string.IsNullOrEmpty(_settingsService.UserIdSetting);
if (result)
{
ProcessSession(_settingsService.UserIdSetting);
result = _sessionResponse.Status;
}
return result;
}