tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
User.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel.DataAnnotations;
4using System.Linq;
5
9
11{
13 public sealed class User : Api.Models.Internal.UserModelBase,
14 ILegacyApiTransformable<UserResponse>,
15 IApiTransformable<User, GraphQL.Types.User, UserGraphQLTransformer>,
16 IApiTransformable<User, GraphQL.Types.UserName, UserNameGraphQLTransformer>
17 {
21 public const string TgsSystemUserName = "TGS";
22
26 public string? PasswordHash { get; set; }
27
31 public User? CreatedBy { get; set; }
32
36 public long? CreatedById { get; set; }
37
41 public UserGroup? Group { get; set; }
42
46 public long? GroupId { get; set; }
47
51 public PermissionSet? PermissionSet { get; set; }
52
56 [Required]
57 [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
58 public string? CanonicalName { get; set; }
59
63 public DateTimeOffset? LastPasswordUpdate { get; set; }
64
68 public ICollection<User>? CreatedUsers { get; set; }
69
73 public ICollection<TestMerge>? TestMerges { get; set; }
74
78 public ICollection<OAuthConnection>? OAuthConnections { get; set; }
79
85 public static string CanonicalizeName(string name) => name?.ToUpperInvariant() ?? throw new ArgumentNullException(nameof(name));
86
89
96 {
97 var result = CreateUserName<UserResponse>();
98 if (recursive)
99 result.CreatedBy = CreatedBy?.CreateUserName<UserName>();
100
101 result.CreatedAt = CreatedAt;
102 result.Enabled = Enabled;
103 result.SystemIdentifier = SystemIdentifier;
104 result.OAuthConnections = OAuthConnections
105 ?.Select(x => x.ToApi())
106 .ToList();
107 result.Group = Group?.ToApi(false);
108 result.PermissionSet = PermissionSet?.ToApi();
109 return result;
110 }
111 }
112}
bool? Enabled
If the UserModelBase is enabled since users cannot be deleted. System users cannot be disabled.
string? SystemIdentifier
The SID/UID of the UserModelBase on Windows/POSIX respectively.
DateTimeOffset? CreatedAt
When the UserModelBase was created.
Sanity limits to prevent users from overloading.
Definition Limits.cs:9
const int MaximumIndexableStringLength
Length limit for NamedEntity.Names.
Definition Limits.cs:23
Base class for user names.
Definition UserName.cs:7
UserName CreateUserName()
Create a copy of the UserName.
Api.Models.PermissionSet ToApi()
Convert the PermissionSet to it's API form.
Represents a group of Users.
Definition UserGroup.cs:16
UserGroupResponse ToApi(bool showUsers)
Convert the UserGroup to it's API form.
ICollection< OAuthConnection >? OAuthConnections
The TestMerges made by the User.
Definition User.cs:78
User? CreatedBy
See UserResponse.
Definition User.cs:31
const string TgsSystemUserName
Username used when creating jobs automatically.
Definition User.cs:21
static string CanonicalizeName(string name)
Change a UserName.Name into a CanonicalName.
ICollection< TestMerge >? TestMerges
The TestMerges made by the User.
Definition User.cs:73
long? GroupId
The EntityId.Id of the User's Group.
Definition User.cs:46
UserResponse CreateUserResponse(bool recursive)
Generate a UserResponse from this.
Definition User.cs:95
string? CanonicalName
The uppercase invariant of UserName.Name.
Definition User.cs:58
DateTimeOffset? LastPasswordUpdate
When PasswordHash was last changed.
Definition User.cs:63
string? PasswordHash
The hash of the user's password.
Definition User.cs:26
long? CreatedById
The EntityId.Id of the User's CreatedBy User.
Definition User.cs:36
ICollection< User >? CreatedUsers
Users created by this User.
Definition User.cs:68
UserGroup? Group
The UserGroup the User belongs to, if any.
Definition User.cs:41
Represents a host-side model that may be transformed into a TApiModel .
Represents a host-side model that may be transformed into a TApiModel .
@ Required
DMAPI validation must suceed for the deployment to succeed.