public async Task <Gamespace[]> List(string filter, CancellationToken ct = default(CancellationToken)) { if (filter == "all") { return(await ListAll(ct)); } var list = await _gamespaceStore.ListByProfile(User.Id).ToArrayAsync(ct); return(Mapper.Map <Gamespace[]>(list)); }
public async Task <Registration> Register(RegistrationRequest registration) { // check client scope / workspace audience var workspace = await _workspaceStore.Load(registration.ResourceId); if (workspace == null) { throw new ResourceNotFound(); } if (!workspace.HasScope(Client.Scope)) { throw new InvalidClientAudience(); } var game = await _gamespaceStore.ListByProfile(registration.SubjectId) .SingleOrDefaultAsync(m => m.GlobalId == registration.ResourceId); string id = game?.GlobalId ?? Guid.NewGuid().ToString(); string token = Guid.NewGuid().ToString("n"); Challenge challenge = null; try { var spec = JsonSerializer.Deserialize <ChallengeSpec>(workspace.Challenge, jsonOptions); challenge = Mapper.Map <Challenge>(spec); challenge.GamespaceId = id; } catch {} return(new Registration { SubjectId = registration.SubjectId, SubjectName = registration.SubjectName, ResourceId = registration.ResourceId, GamespaceId = id, Token = token, RedirectUrl = _options.LaunchUrl + token, ClientId = Client.Id, Challenge = challenge }); }