private void UpdateUser(UserConfiguration userConfig) { LoadDevices(); // Update other pages if (accountpage != null) { accountpage.LoadUserConfiguration(userConfig); } SendCurrentUser(); // Login Server user (set login file) Login(userConfig); // Restart Message monitor StartMessageMonitor(); messageCenter.ClearMessages(); // Load the Profile Image (Nav Menu) LoadProfileImage(userConfig); // Raise CurrentUserChanged Event CurrentUserChanged?.Invoke(userConfig); }
public async Task AuthenticateUser(string providerToken, string providerAuthCode) { try { if (string.IsNullOrEmpty(providerToken)) { throw new ArgumentNullException(nameof(providerToken)); } if (string.IsNullOrEmpty(providerAuthCode)) { throw new ArgumentNullException(nameof(providerAuthCode)); } ResetUser(); var auth = JObject.Parse($"{{'id_token':'{providerToken}','authorization_code':'{providerAuthCode}'}}").ToString(); NetworkIndicator.ToggleVisibility(true); var authResponse = await HttpClient.PostAsync(Routes.LoginGoogle, new StringContent (auth, Encoding.UTF8, Routes.Json)); if (authResponse.IsSuccessStatusCode) { var azureUser = JsonConvert.DeserializeObject <AzureAppServiceUser> (await authResponse.Content.ReadAsStringAsync()); Keychain.SaveItemToKeychain(AzureAppServiceUser.AuthenticationHeader, "azure", azureUser.AuthenticationToken); _httpClient = null; var userConfigJson = await HttpClient.GetStringAsync(Routes.AuthenticateUser); authUser = JsonConvert.DeserializeObject <AuthUserConfig> (userConfigJson); authUser.SaveToKeychain(Keychain); Log.Debug(authUser.ToString()); _user = null; CurrentUserChanged?.Invoke(this, User); } else { Log.Error(auth); Log.Error(authResponse?.ToString()); } } catch (Exception ex) { Log.Error(ex); throw; } finally { NetworkIndicator.ToggleVisibility(false); } }
public void ResetUser() { _user = null; Keychain.RemoveItemFromKeychain(AzureAppServiceUser.AuthenticationHeader); AuthUserConfig.RemoveFromKeychain(Keychain); Settings.SetContentToken <AvContent> (string.Empty); _httpClient = null; ContentClient.Shared.ResetClient(); CurrentUserChanged?.Invoke(this, null); }
public void ResetCurrentUser() { ResetCurrentUserLogin(); var oldUser = CurrentUser; CurrentUser = new User( null, null, -1, null, UserStoreType.Unknown); CurrentUserChanged?.Invoke(this, new UserChangedEventArgs(oldUser, CurrentUser)); }
public bool SetCurrentUserTemporary(string login, string token, int id) { ResetCurrentUserLogin(); var oldUser = CurrentUser; CurrentUser = new User( login, token, id, null, UserStoreType.Temporary); CurrentUserChanged?.Invoke(this, new UserChangedEventArgs(oldUser, CurrentUser)); return(true); }
public bool SetCurrentUser(string login) { if (!IsExistUser(login)) { return(false); } if (!GetUser(login, out var currentUser)) { return(false); } SetCurrentUserLogin(login); var oldUser = CurrentUser; CurrentUser = currentUser; CurrentUserChanged?.Invoke(this, new UserChangedEventArgs(oldUser, CurrentUser)); return(true); }
public void SetCurrentUser(User user) { CurrentUserChanged?.Invoke(user); }
void SendCurrentUserChanged(UserConfiguration userConfig) { CurrentUserChanged?.Invoke(userConfig); }