wip
This commit is contained in:
parent
8471ff8eaf
commit
81b9e4dd68
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.vscode
|
||||
.idea
|
||||
coverage
|
||||
dist
|
||||
node_modules
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
.vscode
|
||||
.idea
|
||||
node_modules
|
||||
coverage
|
||||
src
|
||||
.gitignore
|
||||
tsconfig.json
|
||||
4565
package-lock.json
generated
4565
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,8 +7,8 @@ export interface ITokenService {
|
||||
generate(
|
||||
session: ISession,
|
||||
subject: string,
|
||||
expires: string,
|
||||
algorithm: Algorithm
|
||||
expires?: string,
|
||||
algorithm?: Algorithm
|
||||
): Promise<string>;
|
||||
validate(token: string): Promise<boolean>;
|
||||
getAccount(token: string): Promise<IAccount | null>;
|
||||
|
||||
@ -18,7 +18,11 @@ export class LoginService {
|
||||
private readonly accountService: AccountService
|
||||
) {}
|
||||
|
||||
async signIn(signIn: ISignIn): Promise<string> {
|
||||
async signIn(
|
||||
signIn: ISignIn,
|
||||
expires: string = "1h",
|
||||
algorithm: tokenService.Algorithm = "HS512"
|
||||
): Promise<string> {
|
||||
const accounts = await this.accountService.getBy(
|
||||
(x) =>
|
||||
x.accountName === signIn.accountName &&
|
||||
@ -35,7 +39,12 @@ export class LoginService {
|
||||
return "";
|
||||
}
|
||||
const session = await this.sessionService.create(accounts[0]);
|
||||
const token = await this.tokenService.generate(session);
|
||||
const token = await this.tokenService.generate(
|
||||
session,
|
||||
signIn.accountName,
|
||||
expires,
|
||||
algorithm
|
||||
);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user