forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.ts
More file actions
16 lines (14 loc) · 738 Bytes
/
Copy pathAuth.ts
File metadata and controls
16 lines (14 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { User } from "./User";
import { DatabaseConnection } from "./DatabaseConnection";
import { TokenUser } from "./TokenUser";
import { Crypt } from "./Crypt";
export class Auth {
public static async ValidateByPassword(username:string, password:string): Promise<User> {
if(username===null||username===undefined||username==="") { throw Error("Username cannot be null"); }
if(password===null||password===undefined||password==="") { throw Error("Password cannot be null"); }
var user: User = await User.FindByUsername(username);
if(user===null || user===undefined) { return null; }
if((await Crypt.compare(password, user.passwordhash)) !== true) { return null; }
return user;
}
}