tokens: Add token creation

Fix token deletion
Update plantuml docs
Add token validUntil and lastUsed fields

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-01-21 19:37:43 +01:00 committed by David Mehren
parent cce1626c48
commit c9751404f7
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
9 changed files with 113 additions and 35 deletions

View file

@ -7,9 +7,10 @@
import { Module } from '@nestjs/common';
import { UsersModule } from '../../users/users.module';
import { TokensController } from './tokens/tokens.controller';
import { LoggerModule } from '../../logger/logger.module';
@Module({
imports: [UsersModule],
imports: [UsersModule, LoggerModule],
controllers: [TokensController],
})
export class PrivateApiModule {}

View file

@ -30,9 +30,9 @@ export class TokensController {
@Get()
async getUserTokens(): Promise<AuthTokenDto[]> {
// ToDo: Get real userName
return (await this.usersService.getTokensByUsername('molly')).map((token) =>
this.usersService.toAuthTokenDto(token),
);
return (
await this.usersService.getTokensByUsername('hardcoded')
).map((token) => this.usersService.toAuthTokenDto(token));
}
@Post()
@ -49,10 +49,10 @@ export class TokensController {
return this.usersService.toAuthTokenWithSecretDto(authToken);
}
@Delete('/:timestamp')
@Delete('/:keyId')
@HttpCode(204)
async deleteToken(@Param('timestamp') timestamp: number) {
async deleteToken(@Param('keyId') keyId: string) {
// ToDo: Get real userName
return this.usersService.removeToken('hardcoded', timestamp);
return this.usersService.removeToken('hardcoded', keyId);
}
}