mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-20 00:02:28 +00:00
Fix migrations
This commit is contained in:
parent
8aca781675
commit
dc2c93647f
4 changed files with 13 additions and 20 deletions
|
@ -1,15 +1,15 @@
|
|||
create table ProfileCardLocations
|
||||
create table Locations
|
||||
(
|
||||
UserId int not null,
|
||||
LocationX int not null,
|
||||
LocationY int not null
|
||||
Id int not null,
|
||||
X int not null,
|
||||
Y int not null
|
||||
);
|
||||
|
||||
create unique index ProfileCardLocations_UserId_uindex
|
||||
create unique index Locations_UserId_uindex
|
||||
on Locations (Id);
|
||||
|
||||
alter table Locations
|
||||
add constraint ProfileCardLocations_pk
|
||||
add constraint Locations_pk
|
||||
primary key (Id);
|
||||
|
||||
alter table Users
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
create table Tokens
|
||||
(
|
||||
UserId int not null,
|
||||
MMAuth text not null
|
||||
UserToken text not null
|
||||
);
|
||||
|
||||
create unique index Tokens_MMAuth_uindex
|
||||
on Tokens (MMAuth);
|
||||
|
|
|
@ -39,17 +39,13 @@ namespace ProjectLighthouse {
|
|||
// MM_AUTH=psn_name:?:timestamp, potentially a user creation date?:?:user id?:user's IP:?:password? SHA1
|
||||
// just blindly trust the token for now while we get it working
|
||||
public async Task<bool> AuthenticateUser(string mmAuth) {
|
||||
if(!mmAuth.Contains(':')) return false;
|
||||
|
||||
Token token = new() {
|
||||
MMAuth = mmAuth
|
||||
UserToken = mmAuth
|
||||
};
|
||||
|
||||
string[] split;
|
||||
try {
|
||||
split = mmAuth.Split(":");
|
||||
}
|
||||
catch(ArgumentOutOfRangeException e) {
|
||||
return false; // Token doesn't contain :, cant be a valid token
|
||||
}
|
||||
string[] split = mmAuth.Split(":");
|
||||
|
||||
// TODO: don't use psn name to authenticate
|
||||
User user = await this.Users.FirstOrDefaultAsync(u => u.Username == split[0])
|
||||
|
@ -63,7 +59,7 @@ namespace ProjectLighthouse {
|
|||
public async Task<bool> IsUserAuthenticated(string mmAuth) => await UserFromMMAuth(mmAuth) != null;
|
||||
|
||||
public async Task<User?> UserFromMMAuth(string mmAuth) {
|
||||
Token? token = await Tokens.FirstOrDefaultAsync(t => t.MMAuth == mmAuth);
|
||||
Token? token = await Tokens.FirstOrDefaultAsync(t => t.UserToken == mmAuth);
|
||||
if(token == null) return null;
|
||||
return await Users.FirstOrDefaultAsync(u => u.UserId == token.UserId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ namespace ProjectLighthouse.Types {
|
|||
[Keyless]
|
||||
public class Token {
|
||||
public int UserId { get; set; }
|
||||
public string MMAuth { get; set; }
|
||||
public string UserToken { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue