/// <summary> /// Gets a web account by type. /// </summary> /// <param name="type">Type enum of the web account.</param> /// <returns>WebAccount instance if found else null.</returns> private async Task <WebAccount> GetWebAccount(WebAccountTypes type) { var details = this.GetWebAccountInfo(type); WebAccount account = null; if (details != null) { WebAccountProvider provider = await GetProvider(details.ProviderID, details.Authority); if (provider != null) { account = await WebAuthenticationCoreManager.FindAccountAsync(provider, details.AccountID); } // The account has been deleted if FindAccountAsync returns null if (account == null) { this.DeleteUsersWebAccountDetails(type); } } return(account); }
/// <summary> /// Deletes an authenticated account from storage. /// </summary> /// <param name="type">Enum type representing the web account to delete.</param> private void DeleteUsersWebAccountDetails(WebAccountTypes type) { Platform.Current.Storage.SaveSetting("WAM_" + type.ToString(), null, ApplicationData.Current.RoamingSettings, SerializerTypes.Json); }
/// <summary> /// Indicates whether or not an account is stored in storage. /// </summary> /// <param name="type">Enum type of the web account to check if stored info exists or not.</param> /// <returns>True if stored info exists else false.</returns> private bool HasWebAccountInfo(WebAccountTypes type) { return Platform.Current.Storage.ContainsSetting("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings); }
/// <summary> /// Retrieves an authenticated account details from storage. /// </summary> /// <param name="type"></param> /// <returns>WebAccountInfo instance if found else null.</returns> private WebAccountInfo GetWebAccountInfo(WebAccountTypes type) { return Platform.Current.Storage.LoadSetting<WebAccountInfo>("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings, SerializerTypes.Json); }
/// <summary> /// Gets a web account by type. /// </summary> /// <param name="type">Type enum of the web account.</param> /// <returns>WebAccount instance if found else null.</returns> private async Task<WebAccount> GetWebAccount(WebAccountTypes type) { var details = this.GetWebAccountInfo(type); WebAccount account = null; if (details != null) { WebAccountProvider provider = await GetProvider(details.ProviderID, details.Authority); if (provider != null) account = await WebAuthenticationCoreManager.FindAccountAsync(provider, details.AccountID); // The account has been deleted if FindAccountAsync returns null if (account == null) this.DeleteUsersWebAccountDetails(type); } return account; }
/// <summary> /// Deletes an authenticated account from storage. /// </summary> /// <param name="type">Enum type representing the web account to delete.</param> private void DeleteUsersWebAccountDetails(WebAccountTypes type) { PlatformBase.CurrentCore.Storage.SaveSetting("WAM_" + type.ToString(), null, ApplicationData.Current.RoamingSettings, SerializerTypes.Json); }
/// <summary> /// Indicates whether or not an account is stored in storage. /// </summary> /// <param name="type">Enum type of the web account to check if stored info exists or not.</param> /// <returns>True if stored info exists else false.</returns> private bool HasWebAccountInfo(WebAccountTypes type) { return(PlatformBase.CurrentCore.Storage.ContainsSetting("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings)); }
/// <summary> /// Retrieves an authenticated account details from storage. /// </summary> /// <param name="type"></param> /// <returns>WebAccountInfo instance if found else null.</returns> private WebAccountInfo GetWebAccountInfo(WebAccountTypes type) { return(PlatformBase.CurrentCore.Storage.LoadSetting <WebAccountInfo>("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings, SerializerTypes.Json)); }