public async Task <IActionResult> About() { if (HttpContext.User.Identity.IsAuthenticated) { //update various steam fields on the user var user = await _userManager.GetUserAsync(HttpContext.User); //TODO GET STEAM APIs, add AddSteamUser to factory SteamFactory sf = new SteamFactory(); var response = sf.GetSteamUser(user.SteamId); JObject steamUser = JsonConvert.DeserializeObject(response) as JObject; var temp = steamUser.GetValue("response").First; var t = temp.First; var tr = t.First; Player s = JsonConvert.DeserializeObject <Player>(t.First.ToString()); sf.UpdateSteamUser(user.SteamId, _context); } ViewData["Message"] = "Your application description page."; return(View()); }
public async Task <IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null) { if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; //TODO set username to steam username var steamid = info.ProviderKey.Split('/'); user.SteamId = steamid[5]; user.SteamName = info.Principal.Identity.Name; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user, info); if (result.Succeeded) { SteamFactory sf = new SteamFactory(); sf.UpdateSteamUser(user.SteamId, _context); await _signInManager.SignInAsync(user, isPersistent : false); _logger.LogInformation(6, "User created an account using {Name} provider.", info.LoginProvider); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewData["ReturnUrl"] = returnUrl; return(View(model)); }