tgstation-server 6.8.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
8
10{
12 public sealed class User : Api.Models.Internal.UserModelBase, IApiTransformable<UserResponse>
13 {
17 public const string TgsSystemUserName = "TGS";
18
22 public string? PasswordHash { get; set; }
23
27 public User? CreatedBy { get; set; }
28
32 public UserGroup? Group { get; set; }
33
37 public long? GroupId { get; set; }
38
42 public PermissionSet? PermissionSet { get; set; }
43
47 [Required]
48 [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
49 public string? CanonicalName { get; set; }
50
54 public DateTimeOffset? LastPasswordUpdate { get; set; }
55
59 public ICollection<User>? CreatedUsers { get; set; }
60
64 public ICollection<TestMerge>? TestMerges { get; set; }
65
69 public ICollection<OAuthConnection>? OAuthConnections { get; set; }
70
76 public static string CanonicalizeName(string name) => name?.ToUpperInvariant() ?? throw new ArgumentNullException(nameof(name));
77
80
87 {
88 var result = CreateUserName<UserResponse>();
89 if (recursive)
90 result.CreatedBy = CreatedBy?.CreateUserName<UserName>();
91
92 result.CreatedAt = CreatedAt;
93 result.Enabled = Enabled;
94 result.SystemIdentifier = SystemIdentifier;
95 result.OAuthConnections = OAuthConnections
96 ?.Select(x => x.ToApi())
97 .ToList();
98 result.Group = Group?.ToApi(false);
99 result.PermissionSet = PermissionSet?.ToApi();
100 return result;
101 }
102 }
103}
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:18
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:15
UserGroupResponse ToApi(bool showUsers)
Convert the UserGroup to it's API form.
ICollection< OAuthConnection >? OAuthConnections
The TestMerges made by the User.
Definition: User.cs:69
User? CreatedBy
See UserResponse.
Definition: User.cs:27
const string TgsSystemUserName
Username used when creating jobs automatically.
Definition: User.cs:17
static string CanonicalizeName(string name)
Change a UserName.Name into a CanonicalName.
ICollection< TestMerge >? TestMerges
The TestMerges made by the User.
Definition: User.cs:64
long? GroupId
The ID of the User's UserGroup.
Definition: User.cs:37
UserResponse CreateUserResponse(bool recursive)
Generate a UserResponse from this.
Definition: User.cs:86
string? CanonicalName
The uppercase invariant of UserName.Name.
Definition: User.cs:49
DateTimeOffset? LastPasswordUpdate
When PasswordHash was last changed.
Definition: User.cs:54
string? PasswordHash
The hash of the user's password.
Definition: User.cs:22
ICollection< User >? CreatedUsers
Users created by this User.
Definition: User.cs:59
UserGroup? Group
The UserGroup the User belongs to, if any.
Definition: User.cs:32
Represents a host-side model that may be transformed into a TApiModel .