Cleanup code

This commit is contained in:
jvyden 2021-10-19 15:02:22 -04:00
parent fcd1f25084
commit a41f4516cb
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
16 changed files with 15 additions and 20 deletions

View file

@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using ProjectLighthouse.Types.Files;
using Xunit;

View file

@ -29,7 +29,7 @@ namespace ProjectLighthouse.Controllers {
public IActionResult PrivacySettings() {
PrivacySettings ps = new() {
LevelVisibility = "all",
ProfileVisibility = "all"
ProfileVisibility = "all",
};
return this.Ok(ps.Serialize());

View file

@ -69,7 +69,7 @@ namespace ProjectLighthouse.Controllers {
#region Hearted Levels
[HttpGet("favouriteSlots/{username}")]
public async Task<IActionResult> GetFavouriteSlots(string username) {
public IActionResult GetFavouriteSlots(string username) {
IEnumerable<HeartedLevel> heartedLevels = new Database().HeartedLevels
.Include(q => q.User)
.Include(q => q.Slot)

View file

@ -33,7 +33,7 @@ namespace ProjectLighthouse.Controllers {
return this.Ok(new LoginResult {
AuthTicket = "MM_AUTH=" + token.UserToken,
LbpEnvVer = ServerSettings.ServerName
LbpEnvVer = ServerSettings.ServerName,
}.Serialize());
}
}

View file

@ -14,12 +14,12 @@ namespace ProjectLighthouse.Controllers {
Summary = "test summary",
Image = new NewsImage {
Hash = "4947269c5f7061b27225611ee58a9a91a8031bbe",
Alignment = "right"
Alignment = "right",
},
Id = 1,
Title = "Test Title",
Text = "Test Text",
Date = 1348755214000
Date = 1348755214000,
}.Serialize());
return this.Ok(LbpSerializer.StringElement("news", newsEntry));

View file

@ -40,7 +40,7 @@ namespace ProjectLighthouse.Controllers {
if(user == null) return this.StatusCode(403, "");
XmlReaderSettings settings = new() {
Async = true // this is apparently not default
Async = true, // this is apparently not default
};
bool locationChanged = false;

View file

@ -45,7 +45,7 @@ namespace ProjectLighthouse {
Token token = new() {
UserToken = HashHelper.GenerateAuthToken(),
UserId = user.UserId
UserId = user.UserId,
};
this.Tokens.Add(token);
@ -54,8 +54,6 @@ namespace ProjectLighthouse {
return token;
}
public async Task<bool> IsUserAuthenticated(string authToken) => await this.UserFromAuthToken(authToken) != null;
public async Task<User?> UserFromAuthToken(string authToken) {
Token? token = await Tokens.FirstOrDefaultAsync(t => t.UserToken == authToken);
if(token == null) return null;

View file

@ -3,12 +3,10 @@ using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
namespace ProjectLighthouse {
public class Startup {

View file

@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Xml.Serialization;
using ProjectLighthouse.Serialization;

View file

@ -1,4 +1,3 @@
using System.IO;
using ProjectLighthouse.Helpers;
namespace ProjectLighthouse.Types.Files {

View file

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace ProjectLighthouse.Types {
public class HeartedLevel {
// ReSharper disable once UnusedMember.Global
[Key] public int HeartedLevelId { get; set; }
public int UserId { get; set; }

View file

@ -82,6 +82,6 @@ namespace ProjectLighthouse.Types {
Spikes,
Collectables,
Vertical,
Balancing
Balancing,
}
}

View file

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace ProjectLighthouse.Types {
public class QueuedLevel {
// ReSharper disable once UnusedMember.Global
[Key] public int QueuedLevelId { get; set; }
public int UserId { get; set; }

View file

@ -1,8 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Xml.Serialization;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {

View file

@ -1,6 +1,9 @@
using System.ComponentModel.DataAnnotations;
namespace ProjectLighthouse.Types {
public class Token {
public int TokenId { get; set; }
// ReSharper disable once UnusedMember.Global
[Key] public int TokenId { get; set; }
public int UserId { get; set; }
public string UserToken { get; set; }
}

View file

@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
@ -60,7 +59,7 @@ namespace ProjectLighthouse.Types {
// "lbp1",
"lbp2",
"lbp3",
"crossControl"
"crossControl",
};
private string SerializeSlots() {