Resolve merge conflicts

This commit is contained in:
jvyden 2021-10-16 19:17:46 -04:00
commit c9421b6d23
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
22 changed files with 287 additions and 93 deletions

View file

@ -1,5 +1,3 @@
//#nullable enable
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
@ -11,16 +9,15 @@ namespace ProjectLighthouse {
public DbSet<User> Users { get; set; }
public DbSet<Location> Locations { get; set; }
public DbSet<Slot> Slots { get; set; }
public DbSet<QueuedLevel> QueuedLevels { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<Token> Tokens { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseMySql(
ServerSettings.DbConnectionString,
MySqlServerVersion.LatestSupportedServerVersion
);
public async Task<User> CreateUser(string username) {
Location l = new(); // store to get id after submitting
this.Locations.Add(l); // add to table
@ -29,7 +26,7 @@ namespace ProjectLighthouse {
User user = new() {
Username = username,
LocationId = l.Id,
Biography = "No biography provided",
Biography = username + " hasn't introduced themselves yet.",
Pins = "",
PlanetHash = "",
};
@ -63,7 +60,9 @@ namespace ProjectLighthouse {
public async Task<User?> UserFromAuthToken(string authToken) {
Token? token = await Tokens.FirstOrDefaultAsync(t => t.UserToken == authToken);
if(token == null) return null;
return await Users.FirstOrDefaultAsync(u => u.UserId == token.UserId);
return await Users
.Include(u => u.Location)
.FirstOrDefaultAsync(u => u.UserId == token.UserId);
}
public async Task<User?> UserFromRequest(HttpRequest request) {