mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Cleanup code
This commit is contained in:
parent
fcd1f25084
commit
a41f4516cb
16 changed files with 15 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ProjectLighthouse.Types.Files;
|
using ProjectLighthouse.Types.Files;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace ProjectLighthouse.Controllers {
|
||||||
public IActionResult PrivacySettings() {
|
public IActionResult PrivacySettings() {
|
||||||
PrivacySettings ps = new() {
|
PrivacySettings ps = new() {
|
||||||
LevelVisibility = "all",
|
LevelVisibility = "all",
|
||||||
ProfileVisibility = "all"
|
ProfileVisibility = "all",
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.Ok(ps.Serialize());
|
return this.Ok(ps.Serialize());
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace ProjectLighthouse.Controllers {
|
||||||
#region Hearted Levels
|
#region Hearted Levels
|
||||||
|
|
||||||
[HttpGet("favouriteSlots/{username}")]
|
[HttpGet("favouriteSlots/{username}")]
|
||||||
public async Task<IActionResult> GetFavouriteSlots(string username) {
|
public IActionResult GetFavouriteSlots(string username) {
|
||||||
IEnumerable<HeartedLevel> heartedLevels = new Database().HeartedLevels
|
IEnumerable<HeartedLevel> heartedLevels = new Database().HeartedLevels
|
||||||
.Include(q => q.User)
|
.Include(q => q.User)
|
||||||
.Include(q => q.Slot)
|
.Include(q => q.Slot)
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ProjectLighthouse.Controllers {
|
||||||
|
|
||||||
return this.Ok(new LoginResult {
|
return this.Ok(new LoginResult {
|
||||||
AuthTicket = "MM_AUTH=" + token.UserToken,
|
AuthTicket = "MM_AUTH=" + token.UserToken,
|
||||||
LbpEnvVer = ServerSettings.ServerName
|
LbpEnvVer = ServerSettings.ServerName,
|
||||||
}.Serialize());
|
}.Serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,12 @@ namespace ProjectLighthouse.Controllers {
|
||||||
Summary = "test summary",
|
Summary = "test summary",
|
||||||
Image = new NewsImage {
|
Image = new NewsImage {
|
||||||
Hash = "4947269c5f7061b27225611ee58a9a91a8031bbe",
|
Hash = "4947269c5f7061b27225611ee58a9a91a8031bbe",
|
||||||
Alignment = "right"
|
Alignment = "right",
|
||||||
},
|
},
|
||||||
Id = 1,
|
Id = 1,
|
||||||
Title = "Test Title",
|
Title = "Test Title",
|
||||||
Text = "Test Text",
|
Text = "Test Text",
|
||||||
Date = 1348755214000
|
Date = 1348755214000,
|
||||||
}.Serialize());
|
}.Serialize());
|
||||||
|
|
||||||
return this.Ok(LbpSerializer.StringElement("news", newsEntry));
|
return this.Ok(LbpSerializer.StringElement("news", newsEntry));
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace ProjectLighthouse.Controllers {
|
||||||
if(user == null) return this.StatusCode(403, "");
|
if(user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
XmlReaderSettings settings = new() {
|
XmlReaderSettings settings = new() {
|
||||||
Async = true // this is apparently not default
|
Async = true, // this is apparently not default
|
||||||
};
|
};
|
||||||
|
|
||||||
bool locationChanged = false;
|
bool locationChanged = false;
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace ProjectLighthouse {
|
||||||
|
|
||||||
Token token = new() {
|
Token token = new() {
|
||||||
UserToken = HashHelper.GenerateAuthToken(),
|
UserToken = HashHelper.GenerateAuthToken(),
|
||||||
UserId = user.UserId
|
UserId = user.UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Tokens.Add(token);
|
this.Tokens.Add(token);
|
||||||
|
@ -54,8 +54,6 @@ namespace ProjectLighthouse {
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> IsUserAuthenticated(string authToken) => await this.UserFromAuthToken(authToken) != null;
|
|
||||||
|
|
||||||
public async Task<User?> UserFromAuthToken(string authToken) {
|
public async Task<User?> UserFromAuthToken(string authToken) {
|
||||||
Token? token = await Tokens.FirstOrDefaultAsync(t => t.UserToken == authToken);
|
Token? token = await Tokens.FirstOrDefaultAsync(t => t.UserToken == authToken);
|
||||||
if(token == null) return null;
|
if(token == null) return null;
|
||||||
|
|
|
@ -3,12 +3,10 @@ using System.IO;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using ProjectLighthouse.Serialization;
|
using ProjectLighthouse.Serialization;
|
||||||
using ProjectLighthouse.Types;
|
|
||||||
|
|
||||||
namespace ProjectLighthouse {
|
namespace ProjectLighthouse {
|
||||||
public class Startup {
|
public class Startup {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using ProjectLighthouse.Serialization;
|
using ProjectLighthouse.Serialization;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System.IO;
|
|
||||||
using ProjectLighthouse.Helpers;
|
using ProjectLighthouse.Helpers;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types.Files {
|
namespace ProjectLighthouse.Types.Files {
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
public class HeartedLevel {
|
public class HeartedLevel {
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
[Key] public int HeartedLevelId { get; set; }
|
[Key] public int HeartedLevelId { get; set; }
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
|
@ -82,6 +82,6 @@ namespace ProjectLighthouse.Types {
|
||||||
Spikes,
|
Spikes,
|
||||||
Collectables,
|
Collectables,
|
||||||
Vertical,
|
Vertical,
|
||||||
Balancing
|
Balancing,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
public class QueuedLevel {
|
public class QueuedLevel {
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
[Key] public int QueuedLevelId { get; set; }
|
[Key] public int QueuedLevelId { get; set; }
|
||||||
|
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
using ProjectLighthouse.Serialization;
|
using ProjectLighthouse.Serialization;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
public class Token {
|
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 int UserId { get; set; }
|
||||||
public string UserToken { get; set; }
|
public string UserToken { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using ProjectLighthouse.Serialization;
|
using ProjectLighthouse.Serialization;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Types {
|
namespace ProjectLighthouse.Types {
|
||||||
|
@ -60,7 +59,7 @@ namespace ProjectLighthouse.Types {
|
||||||
// "lbp1",
|
// "lbp1",
|
||||||
"lbp2",
|
"lbp2",
|
||||||
"lbp3",
|
"lbp3",
|
||||||
"crossControl"
|
"crossControl",
|
||||||
};
|
};
|
||||||
|
|
||||||
private string SerializeSlots() {
|
private string SerializeSlots() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue