Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class LoginController : ControllerBase
{
private readonly DatabaseContext database;
public LoginController(DatabaseContext database)

Check notice on line 23 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Convert constructor into primary constructor

Convert into primary constructor
{
this.database = database;
}
Expand Down Expand Up @@ -74,7 +74,7 @@
case Platform.PS3:
case Platform.Vita:
case Platform.UnitTest:
user = await database.Users.FirstOrDefaultAsync(u => u.LinkedPsnId == npTicket.UserId);

Check notice on line 77 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
break;
case Platform.PSP:
case Platform.Unknown:
Expand All @@ -86,7 +86,7 @@
if (user == null)
{
// Check if there is an account with that username already
UserEntity? targetUsername = await database.Users.FirstOrDefaultAsync(u => u.Username == npTicket.Username);

Check notice on line 89 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
if (targetUsername != null)
{
ulong targetPlatform = npTicket.Platform == Platform.RPCS3
Expand All @@ -101,7 +101,7 @@
}

// if there is already a pending link request don't create another
bool linkAttemptExists = await database.PlatformLinkAttempts.AnyAsync(p =>

Check notice on line 104 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
p.Platform == npTicket.Platform &&
p.PlatformId == npTicket.UserId &&
p.UserId == targetUsername.UserId);
Expand All @@ -116,8 +116,8 @@
Timestamp = TimeHelper.TimestampMillis,
PlatformId = npTicket.UserId,
};
database.PlatformLinkAttempts.Add(linkAttempt);

Check notice on line 119 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
await database.SaveChangesAsync();

Check notice on line 120 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
Logger.Success($"User '{npTicket.Username}' tried to login but platform isn't linked, platform={npTicket.Platform}", LogArea.Login);
return this.Forbid();
}
Expand Down Expand Up @@ -147,11 +147,11 @@
}

// create account for user if they don't exist
user = await database.CreateUser(username, "$");

Check notice on line 150 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
user.Password = null;
user.LinkedRpcnId = npTicket.Platform == Platform.RPCS3 ? npTicket.UserId : 0;
user.LinkedPsnId = npTicket.Platform != Platform.RPCS3 ? npTicket.UserId : 0;
await database.SaveChangesAsync();

Check notice on line 154 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing

if (DiscordConfiguration.Instance.DiscordIntegrationEnabled)
{
Expand All @@ -171,7 +171,7 @@
// automatically change username if it doesn't match
else if (user.Username != npTicket.Username)
{
bool usernameExists = await database.Users.AnyAsync(u => u.Username == npTicket.Username);

Check notice on line 174 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
if (usernameExists)
{
Logger.Warn($"{npTicket.Platform} user changed their name to a name that is already taken," +
Expand All @@ -180,17 +180,17 @@
}
Logger.Info($"User's username has changed, old='{user.Username}', new='{npTicket.Username}', platform={npTicket.Platform}", LogArea.Login);
user.Username = username;
await database.PlatformLinkAttempts.RemoveWhere(p => p.UserId == user.UserId);

Check notice on line 183 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
// unlink other platforms because the names no longer match
if (npTicket.Platform == Platform.RPCS3)
user.LinkedPsnId = 0;
else
user.LinkedRpcnId = 0;

await database.SaveChangesAsync();

Check notice on line 190 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
}

GameTokenEntity? token = await database.GameTokens.Include(t => t.User)

Check notice on line 193 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
.FirstOrDefaultAsync(t => t.User.Username == npTicket.Username && t.TicketHash == npTicket.TicketHash);

if (token != null)
Expand All @@ -199,7 +199,7 @@
return this.Forbid();
}

token = await database.AuthenticateUser(user, npTicket, ipAddress);

Check notice on line 202 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
if (token == null)
{
Logger.Warn($"Unable to find/generate a token for username {npTicket.Username}", LogArea.Login);
Expand All @@ -214,9 +214,13 @@

Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);

user.LastLogin = TimeHelper.TimestampMillis;
string userAgent = this.Request.Headers.UserAgent.ToString();
if (!String.IsNullOrWhiteSpace(userAgent))

Check notice on line 218 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Replace built-in type reference with a CLR type name or a keyword in static member access expressions

Built-in type reference is inconsistent with code style settings
{
user.UserAgent = userAgent;
}

await database.SaveChangesAsync();

Check notice on line 223 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing

// Create a new room on LBP2/3/Vita
if (token.GameVersion != GameVersion.LittleBigPlanet1) RoomHelper.CreateRoom(user.UserId, token.GameVersion, token.Platform);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -17,7 +17,7 @@

private readonly DatabaseContext database;

public LogoutController(DatabaseContext database)

Check notice on line 20 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Convert constructor into primary constructor

Convert into primary constructor
{
this.database = database;
}
Expand All @@ -30,10 +30,7 @@
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Forbid();

user.LastLogout = TimeHelper.TimestampMillis;

await this.database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId);
await this.database.LastContacts.RemoveWhere(c => c.UserId == token.UserId);
await LogoutHelper.Logout(token, user, database);

Check notice on line 33 in ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing

return this.Ok();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Globalization;

Check warning on line 1 in ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed
using System.Text;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
Expand All @@ -7,6 +8,7 @@
using LBPUnion.ProjectLighthouse.Localization.StringLists;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
Expand Down Expand Up @@ -42,7 +44,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.";

public MessageController(DatabaseContext database)

Check notice on line 47 in ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Convert constructor into primary constructor

Convert into primary constructor
{
this.database = database;
}
Expand All @@ -54,6 +56,10 @@
public async Task<IActionResult> Announce()
{
GameTokenEntity token = this.GetToken();
UserEntity? user = await this.database.UserFromGameToken(token);

if (user == null)
return this.Forbid();

string username = await this.database.UsernameFromGameToken(token);

Expand All @@ -67,12 +73,24 @@
announceText.Insert(0, BaseLayoutStrings.ReadOnlyWarn.Translate(LocalizationManager.DefaultLang) + "\n\n");
}

if (ServerConfiguration.Instance.RequirePatchworkUserAgent)
{
announceText.Append("This server instance requires the use of the Patchwork plugin for LBP.\n\n");

if (PatchworkHelper.userHasValidPatchworkUserAgent(user.UserAgent))
{
announceText.Append("It appears you do not have the Patchwork plugin installed correctly." +
"Since this server instance requires it, you will not be able to play until you so.");
}
await LogoutHelper.Logout(token, user, database);

Check notice on line 85 in ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Add/remove 'this.' qualifier

Qualifier 'this.' is missing
}

#if DEBUG
announceText.Append("\n\n---DEBUG INFO---\n" +
$"user.UserId: {token.UserId}\n" +
$"token.GameVersion: {token.GameVersion}\n" +
$"token.TicketHash: {token.TicketHash}\n" +
$"token.ExpiresAt: {token.ExpiresAt.ToString()}\n" +

Check warning on line 93 in ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Specify string culture explicitly

Specify string culture explicitly
"---DEBUG INFO---");
#endif

Expand Down Expand Up @@ -128,7 +146,7 @@

if (message.StartsWith("/setemail ") && ServerConfiguration.Instance.Mail.MailEnabled)
{
string email = message[(message.IndexOf(" ", StringComparison.Ordinal)+1)..];

Check notice on line 149 in ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

RoslynAnalyzers Use char overload

Use 'string.IndexOf(char)' instead of 'string.IndexOf(string)' when you have a string with a single char
if (!SanitizationHelper.IsValidEmail(email)) return this.Ok();

if (await this.database.Users.AnyAsync(u => u.EmailAddress == email)) return this.Ok();
Expand Down
18 changes: 18 additions & 0 deletions ProjectLighthouse.Servers.GameServer/Helpers/LogoutHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;

namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;

public class LogoutHelper

Check notice on line 9 in ProjectLighthouse.Servers.GameServer/Helpers/LogoutHelper.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Class is never instantiated (non-private accessibility)

Class 'LogoutHelper' is never instantiated
{
public static async Task Logout(GameTokenEntity token, UserEntity user, DatabaseContext database)
{
user.LastLogout = TimeHelper.TimestampMillis;

await database.GameTokens.RemoveWhere(t => t.TokenId == token.TokenId);
await database.LastContacts.RemoveWhere(c => c.UserId == token.UserId);
}
}
20 changes: 20 additions & 0 deletions ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using LBPUnion.ProjectLighthouse.Configuration;

namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;

public static class PatchworkHelper
{
static int patchworkMajorVer = ServerConfiguration.Instance.PatchworkMajorVersionMinimum;

Check notice on line 7 in ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Field can be made readonly (private accessibility)

Field can be made readonly
static int patchworkMinorVer = ServerConfiguration.Instance.PatchworkMinorVersionMinimum;

Check notice on line 8 in ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Field can be made readonly (private accessibility)

Field can be made readonly
public static bool userHasValidPatchworkUserAgent(string userAgent)
{
if (userAgent.StartsWith("PatchworkLBP"))
return false;

string[] patchworkVer = userAgent.Split(' ')[1].Split('.');
if (int.Parse(patchworkVer[0]) >= patchworkMajorVer && int.Parse(patchworkVer[1]) >= patchworkMinorVer)

Check notice on line 15 in ProjectLighthouse.Servers.GameServer/Helpers/PatchworkHelper.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

'if-return' statement can be rewritten as 'return' statement

Convert into 'return' statement
return true;

return false;
}
}
7 changes: 6 additions & 1 deletion ProjectLighthouse/Configuration/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,44 @@
// This is so Lighthouse can properly identify outdated configurations and update them with newer settings accordingly.
// If you are modifying anything here, this value MUST be incremented.
// Thanks for listening~
public override int ConfigVersion { get; set; } = 27;
public override int ConfigVersion { get; set; } = 28;

public override string ConfigName { get; set; } = "lighthouse.yml";
public string WebsiteListenUrl { get; set; } = "http://localhost:10060";

Check notice on line 17 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public string GameApiListenUrl { get; set; } = "http://localhost:10061";

Check notice on line 18 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public string ApiListenUrl { get; set; } = "http://localhost:10062";

Check notice on line 19 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only

public string DbConnectionString { get; set; } = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
public string RedisConnectionString { get; set; } = "redis://localhost:6379";

Check notice on line 22 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public string ExternalUrl { get; set; } = "http://localhost:10060";

Check notice on line 23 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public string GameApiExternalUrl { get; set; } = "http://localhost:10060/LITTLEBIGPLANETPS3_XML";

Check notice on line 24 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public string EulaText { get; set; } = "";
#if !DEBUG
public string AnnounceText { get; set; } = "You are now logged in as %user.";
#else
public string AnnounceText { get; set; } = "You are now logged in as %user (id: %id).";
#endif
public bool CheckForUnsafeFiles { get; set; } = true;

Check notice on line 31 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public bool LogChatFiltering { get; set; } = false;

Check notice on line 32 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public bool LogChatMessages { get; set; } = false;

Check notice on line 33 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only

// Require use of Zaprit's "Patchwork" prx plugin's user agent when connecting to the server
// Major and minor version minimums can be left alone if patchwork is not required
public bool RequirePatchworkUserAgent { get; set; } = false;

Check notice on line 37 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public int PatchworkMajorVersionMinimum { get; set; } = 0;

Check notice on line 38 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public int PatchworkMinorVersionMinimum { get; set; } = 0;

Check notice on line 39 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public AuthenticationConfiguration Authentication { get; set; } = new();

Check notice on line 40 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public CaptchaConfiguration Captcha { get; set; } = new();

Check notice on line 41 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public DigestKeyConfiguration DigestKey { get; set; } = new();

Check notice on line 42 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public MatchmakingConfiguration Matchmaking { get; set; } = new();

Check notice on line 43 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public GoogleAnalyticsConfiguration GoogleAnalytics { get; set; } = new();

Check notice on line 44 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public MailConfiguration Mail { get; set; } = new();

Check notice on line 45 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public UserGeneratedContentLimitConfiguration UserGeneratedContentLimits { get; set; } = new();

Check notice on line 46 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public WebsiteConfiguration WebsiteConfiguration { get; set; } = new();

Check notice on line 47 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public CustomizationConfiguration Customization { get; set; } = new();

Check notice on line 48 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public RateLimitConfiguration RateLimitConfiguration { get; set; } = new();

Check notice on line 49 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public TwoFactorConfiguration TwoFactorConfiguration { get; set; } = new();

Check notice on line 50 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public RichPresenceConfiguration RichPresenceConfiguration { get; set; } = new();

Check notice on line 51 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
public NotificationConfiguration NotificationConfiguration { get; set; } = new();

Check notice on line 52 in ProjectLighthouse/Configuration/ServerConfiguration.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only

public override ConfigurationBase<ServerConfiguration> Deserialize(IDeserializer deserializer, string text) => deserializer.Deserialize<ServerConfiguration>(text);
Expand Down
2 changes: 2 additions & 0 deletions ProjectLighthouse/Types/Entities/Profile/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

#nullable enable
[Key]
public int UserId { get; set; }

Check notice on line 17 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Property can be made init-only (non-private accessibility)

Property can be made init-only

public string Username { get; set; } = "";

Check warning on line 19 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

#nullable enable

Check warning on line 21 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant nullable directive

Redundant nullable directive
public string? EmailAddress { get; set; }

Check warning on line 22 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length
#nullable disable

public bool EmailAddressVerified { get; set; }

public string Password { get; set; }

Check warning on line 27 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string IconHash { get; set; }

Check warning on line 29 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string UserAgent { get; set;}

Check warning on line 31 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

/// <summary>
/// Markup that displays the username next to a polaroid with the user's icon.
/// This can be used everywhere markup works ingame, e.g. news or notifications
Expand All @@ -38,7 +40,7 @@
/// <summary>
/// A user-customizable biography shown on the profile card
/// </summary>
public string Biography { get; set; }

Check warning on line 43 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

[NotMapped]
public string WebsiteAvatarHash {
Expand Down Expand Up @@ -75,24 +77,24 @@
set => this.LocationPacked = (ulong)value.X << 32 | (uint)value.Y;
}

public string Pins { get; set; } = "";

Check warning on line 80 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string PlanetHashLBP2 { get; set; } = "";

Check warning on line 82 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

// ReSharper disable once InconsistentNaming
public string PlanetHashLBP2CC { get; set; } = "";

Check warning on line 85 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string PlanetHashLBP3 { get; set; } = "";

Check warning on line 87 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string PlanetHashLBPVita { get; set; } = "";

Check warning on line 89 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public bool PasswordResetRequired { get; set; }

public string YayHash { get; set; } = "";

Check warning on line 93 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length
public string BooHash { get; set; } = "";

Check warning on line 94 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length
public string MehHash { get; set; } = "";

Check warning on line 95 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public long LastLogin { get; set; }

Check notice on line 97 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Property can be made init-only (non-private accessibility)

Property can be made init-only
public long LastLogout { get; set; }

public bool IsBanned => this.PermissionLevel is PermissionLevel.Banned;
Expand All @@ -108,12 +110,12 @@
public PermissionLevel PermissionLevel { get; set; } = PermissionLevel.Default;

#nullable enable
public string? BannedReason { get; set; }

Check warning on line 113 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length
#nullable disable

public string Language { get; set; } = "en";

Check warning on line 116 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string TimeZone { get; set; } = TimeZoneInfo.Local.Id;

Check warning on line 118 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public PrivacyType LevelVisibility { get; set; } = PrivacyType.All;

Expand All @@ -124,9 +126,9 @@

public bool IsTwoFactorSetup => this.TwoFactorBackup?.Length > 0 && this.TwoFactorSecret?.Length > 0;

public string TwoFactorSecret { get; set; } = "";

Check warning on line 129 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public string TwoFactorBackup { get; set; } = "";

Check warning on line 131 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

public ulong LinkedRpcnId { get; set; }

Expand All @@ -139,7 +141,7 @@
// should not be adjustable by user
public bool CommentsEnabled { get; set; } = true;

public string ProfileTag { get; set; } = "";

Check warning on line 144 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible performance issues caused by unlimited string length

Possible performance issues caused by unlimited string length

#nullable enable
public override bool Equals(object? obj)
Expand All @@ -161,4 +163,4 @@

[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode() => this.UserId;
#nullable disable

Check warning on line 166 in ProjectLighthouse/Types/Entities/Profile/UserEntity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Unused nullable directive

Unused nullable directive
Expand Down
Loading