public async Task <UserStatsViewModel> GetUserInfo() { if (User.Identity.IsAuthenticated) { string userId = User.Identity.GetResolvedUserId(); ApplicationUser user = _dbContext.Users.Include(u => u.MemberOf).FirstOrDefault(e => e.Id == userId); if (user == null) { Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); return(null); } UserStatsViewModel model = new UserStatsViewModel(user, true); if (user.SteamID != null && string.IsNullOrEmpty(user.AvatarFull)) { model = await SteamServiceProvider.GetSteamUserDetails(user.SteamID).ConfigureAwait(false); model.SetUser(user); } model.externalLogins = UserManager.GetLogins(user.Id).Select(t => t.LoginProvider).ToList(); return(model); } return(null); }
public async Task <IHttpActionResult> Login(LoginBindingModel login) { var user = await UserManager.FindAsync(login.UserName, login.Password).ConfigureAwait(false); if (user != null) { var identity = await UserManager.CreateIdentityAsync(user, CookieAuthenticationDefaults.AuthenticationType).ConfigureAwait(false); Authentication.SignIn(new AuthenticationProperties() { IsPersistent = login.RememberMe }, identity); UserStatsViewModel model = new UserStatsViewModel(user, true); if (string.IsNullOrEmpty(user.AvatarFull) && !Guid.TryParse(user.Id, out Guid newguid)) { model = await SteamServiceProvider.GetSteamUserDetails(user.Id).ConfigureAwait(false); model.SetUser(user); } model.externalLogins = UserManager.GetLogins(user.Id).Select(t => t.LoginProvider).ToList(); return(Ok(model)); } return(BadRequest("Invalid username or password.")); }
public async Task <UserStatsViewModel> GetSteamUserDetails() { UserStatsViewModel model = await SteamServiceProvider.GetSteamUserDetails(id).ConfigureAwait(false); steamUser = model.steamUser; steamUserException = model.steamUserException; userStats = model.userStats; userStatsException = model.userStatsException; RefreshAppUserValues(); return(this); }
public async Task <IHttpActionResult> GetUserDetails(string userid) { UserStatsViewModel user = await SteamServiceProvider.GetSteamUserDetails(userid).ConfigureAwait(false); ApplicationUser registered = null; if (user.steamUser != null) { registered = _dbContext.Users.Include(u => u.MemberOf).FirstOrDefault(u => u.Id == user.steamUser.steamID64); } if (registered != null) { user.SetUser(registered); } return(Ok(user)); }
public async Task <IHttpActionResult> Search(string name) { SearchResultViewModel results = new SearchResultViewModel(); if (!string.IsNullOrEmpty(name)) { results.Teams = _dbContext.Teams.Where(t => t.Visible && t.TeamName.Contains(name)).ToList(); results.Strategies = _dbContext.Strategies.Where(s => s.Visible && s.Title.Contains(name)).ToList(); List <ApplicationUser> activeUsers = _dbContext.Users.Where(u => u.SearchVisible && u.UserName.Contains(name)).ToList(); foreach (ApplicationUser user in activeUsers) { results.Players.Add(new UserStatsViewModel(user)); } if (!activeUsers.Any(u => u.UserName == name)) { results.SteamUser = await SteamServiceProvider.GetSteamUserDetails(name).ConfigureAwait(false); } return(Ok(results)); } return(Ok(results)); }
public async Task <IHttpActionResult> GetUserGroups(string userid) { UserStatsViewModel user = await SteamServiceProvider.GetSteamUserDetails(userid).ConfigureAwait(false); return(Ok(user?.steamUser?.groups)); }