This commit is contained in:
admin 2025-08-21 20:52:45 +02:00
parent 8471ff8eaf
commit 81b9e4dd68
5 changed files with 4578 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.vscode .vscode
.idea .idea
coverage
dist dist
node_modules node_modules

View File

@ -1,6 +1,7 @@
.vscode .vscode
.idea .idea
node_modules node_modules
coverage
src src
.gitignore .gitignore
tsconfig.json tsconfig.json

4565
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@ export interface ITokenService {
generate( generate(
session: ISession, session: ISession,
subject: string, subject: string,
expires: string, expires?: string,
algorithm: Algorithm algorithm?: Algorithm
): Promise<string>; ): Promise<string>;
validate(token: string): Promise<boolean>; validate(token: string): Promise<boolean>;
getAccount(token: string): Promise<IAccount | null>; getAccount(token: string): Promise<IAccount | null>;

View File

@ -18,7 +18,11 @@ export class LoginService {
private readonly accountService: AccountService 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( const accounts = await this.accountService.getBy(
(x) => (x) =>
x.accountName === signIn.accountName && x.accountName === signIn.accountName &&
@ -35,7 +39,12 @@ export class LoginService {
return ""; return "";
} }
const session = await this.sessionService.create(accounts[0]); 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; return token;
} }