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
13 lines (13 loc) · 715 Bytes
/
Copy pathAuth.ts
File metadata and controls
13 lines (13 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
import { Crypt } from "./Crypt";
import { User } from "openflow-api";
import { DBHelper } from "./DBHelper";
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 DBHelper.FindByUsername(username);
if (user === null || user === undefined) { return null; }
if ((await Crypt.compare(password, user.passwordhash)) !== true) { return null; }
return user;
}
}