private ActionResult LogOn(Identifier identifier) { //Remove the unnecessary portion of the identifier string steamIDString = identifier.ToString().Replace("http://steamcommunity.com/openid/id/", ""); long steamId64 = long.Parse(steamIDString); using (var db = new SprayContext()) { var user = db.Users.FirstOrDefault(x => x.SteamId == steamId64); SteamWebAPI.SteamAPISession session = new SteamWebAPI.SteamAPISession(); session.accessToken = ""; /* CHANGEME - Steam Web API access token */ var userInfo = session.GetUserInfo(steamId64.ToString()); if (user == null) { //Add the user if they're new user = CreateUser(steamId64, db, userInfo); } else { // Or update the relevant information user.AvatarURI = userInfo.avatarUrl; user.NickName = userInfo.nickname; user.LastUpdated = DateTime.Now; } int recordsAffected = db.SaveChanges(); FormsAuthentication.SetAuthCookie(steamId64.ToString(), true); } return(RedirectToAction("Index", "Home")); }
private ActionResult LogOn(Identifier identifier) { //Remove the unnecessary portion of the identifier string steamIDString = identifier.ToString().Replace("http://steamcommunity.com/openid/id/", ""); long steamId64 = long.Parse(steamIDString); using (var db = new SprayContext()) { var user = db.Users.FirstOrDefault(x => x.SteamId == steamId64); SteamWebAPI.SteamAPISession session = new SteamWebAPI.SteamAPISession(); session.accessToken = ""; /* CHANGEME - Steam Web API access token */ var userInfo = session.GetUserInfo(steamId64.ToString()); if (user == null) { //Add the user if they're new user = CreateUser(steamId64, db, userInfo); } else { // Or update the relevant information user.AvatarURI = userInfo.avatarUrl; user.NickName = userInfo.nickname; user.LastUpdated = DateTime.Now; } int recordsAffected = db.SaveChanges(); FormsAuthentication.SetAuthCookie(steamId64.ToString(), true); } return RedirectToAction("Index", "Home"); }