tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
Users.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3using System.Threading;
4using System.Threading.Tasks;
5
6using HotChocolate;
7using HotChocolate.Data;
8using HotChocolate.Types;
9using HotChocolate.Types.Relay;
10
14
15#pragma warning disable CA1724 // conflict with GitLabApiClient.Models.Users. They can fuck off
16
18{
22 public sealed class Users
23 {
28 public UserGroups Groups() => new();
29
36 [TgsGraphQLAuthorize<IUserAuthority>(nameof(IUserAuthority.Read))]
37 public ValueTask<User> Current(
38 [Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority,
39 CancellationToken cancellationToken)
40 {
41 ArgumentNullException.ThrowIfNull(userAuthority);
42 return userAuthority.InvokeTransformable<Models.User, User, UserGraphQLTransformer>(authority => authority.Read(cancellationToken));
43 }
44
52 [Error(typeof(ErrorMessageException))]
53 [TgsGraphQLAuthorize<IUserAuthority>(nameof(IUserAuthority.GetId))]
54 public ValueTask<User?> ById(
55 [ID(nameof(User))] long id,
56 [Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority,
57 CancellationToken cancellationToken)
58 => User.GetUser(id, userAuthority, cancellationToken);
59
65 [UsePaging]
66 [UseFiltering]
67 [UseSorting]
68 [TgsGraphQLAuthorize<IUserAuthority>(nameof(IUserAuthority.Queryable))]
70 [Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
71 {
72 ArgumentNullException.ThrowIfNull(userAuthority);
73 var dtoQueryable = userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(authority => authority.Queryable(false));
74 return dtoQueryable;
75 }
76 }
77}
Exception representing ErrorMessageResponses.
Wrapper for accessing UserGroups.
Definition UserGroups.cs:21
A user registered in the server.
Definition User.cs:21
static ValueTask< User?> GetUser(long id, [Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority, CancellationToken cancellationToken)
Node resolver for Users.
Definition User.cs:62
Wrapper for accessing Users.
Definition Users.cs:23
UserGroups Groups()
Gets the swarm's UserGroups.
IQueryable< User > QueryableUsers([Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority)
Queries all registered Users.
Definition Users.cs:69
ValueTask< User > Current([Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority, CancellationToken cancellationToken)
Gets the current User.
Definition Users.cs:37
ValueTask< User?> ById([ID(nameof(User))] long id, [Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority, CancellationToken cancellationToken)
Gets a User by Entity.Id.
ITransformer<TInput, TOutput> for GraphQL.Types.Users.
IQueryable< User > Queryable(bool includeJoins)
Gets all registered Users.
ValueTask< AuthorityResponse< User > > GetId(long id, bool includeJoins, bool allowSystemUser, CancellationToken cancellationToken)
Gets the User with a given id .
ValueTask< AuthorityResponse< User > > Read(CancellationToken cancellationToken)
Gets the currently authenticated user.