/// <summary> /// Gets the authentication data. /// </summary> private async void GetAuthenticationData() { try { string filename = Path.Combine(folderPath, AuthenticationDataFile); Java.IO.File file = new Java.IO.File(filename); if (file.Exists()) { using (var streamReader = new StreamReader(filename)) { string tokenContent = streamReader.ReadToEnd(); Token token = new Token { Value = tokenContent.Replace("\n", "") }; if (tokenContent != null) { LoginRepository loginRepository = new LoginRepository(); ApplicationData.User = await loginRepository.ValidateToken(token); if (ApplicationData.User != null) { SetAuthenticationData(ApplicationData.User.Token, true); } } } } else { IsRedirectToLogin = true; } return; } catch (Exception e) { IsRedirectToLogin = true; } return; }
private async Task GetAuthenticationData() { try { var tokenByte = this.ReadTokenFromFile(); var tokenContent = Encoding.UTF8.GetString(tokenByte, 0, tokenByte.Length); if (!string.IsNullOrEmpty(tokenContent)) { Token token = new Token { Value = tokenContent.Replace("\n", "") }; LoginRepository loginRepository = new LoginRepository(); ApplicationData.User = await loginRepository.ValidateToken(token); if (ApplicationData.User != null) { SetAuthenticationData(ApplicationData.User.Token, true); } } else { IsRedirectToLogin = true; } return; } catch (Exception e) { IsRedirectToLogin = true; } return; }