Skip to content

Commit a1d41bf

Browse files
author
tenevdev
committed
Update App.xaml live login method
1 parent 1d5e828 commit a1d41bf

File tree

1 file changed

+27
-13
lines changed
  • ClumsyWordsUniversal/ClumsyWordsUniversal.Shared

1 file changed

+27
-13
lines changed

ClumsyWordsUniversal/ClumsyWordsUniversal.Shared/App.xaml.cs

+27-13
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,25 @@ public static string AccountState
172172
public static string LastName { get; set; }
173173
public static string ProfilePictureSource { get; set; }
174174

175+
private static IEnumerable<string> DetermineLoginScopes()
176+
{
177+
List<string> scopes = new List<string>() { "wl.basic" };
178+
179+
ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;
180+
181+
// Check if user has given consent to save data into their SkyDrive storage.
182+
if (roamingSettings.Values.ContainsKey("saveSkyDrive"))
183+
{
184+
if ((bool)roamingSettings.Values["saveSkyDrive"])
185+
{
186+
scopes.Add("wl.skydrive");
187+
scopes.Add("wl.skydrive_upload");
188+
}
189+
}
190+
191+
return scopes;
192+
}
193+
175194
/// <summary>
176195
/// Tries signing in the user with their Microsoft account
177196
/// </summary>
@@ -199,22 +218,17 @@ public static async Task UpdateUserName(Boolean signIn)
199218
// has not already given consent to this app to access the data
200219
// described by the scope.
201220

202-
List<string> scopes = new List<string>() { "wl.basic" };
221+
List<string> scopes = DetermineLoginScopes().ToList();
203222

204-
ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;
205-
206-
// Check if user has given consent to save data into their SkyDrive storage.
207-
if (roamingSettings.Values.ContainsKey("saveSkyDrive"))
223+
// Sign in the user with the given scopes
224+
try
208225
{
209-
if ((bool)roamingSettings.Values["saveSkyDrive"])
210-
{
211-
scopes.Add("wl.skydrive");
212-
scopes.Add("wl.skydrive_upload");
213-
}
226+
loginResult = await LCAuth.LoginAsync(scopes);
227+
}
228+
catch(Exception ex)
229+
{
230+
string m = ex.Message;
214231
}
215-
216-
// Sign in the user with the given scopes
217-
loginResult = await LCAuth.LoginAsync(scopes);
218232
}
219233
else
220234
{

0 commit comments

Comments
 (0)