mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
tests: Fix tests as part of the DTO Refactor
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b07d6d478c
commit
a7f35aaeec
3 changed files with 21 additions and 15 deletions
|
@ -5,14 +5,20 @@
|
|||
*/
|
||||
|
||||
import { ExecutionContext, Injectable } from '@nestjs/common';
|
||||
import { UsersService } from '../users/users.service';
|
||||
import { User } from '../users/user.entity';
|
||||
|
||||
@Injectable()
|
||||
export class MockAuthGuard {
|
||||
canActivate(context: ExecutionContext) {
|
||||
private user: User;
|
||||
constructor(private usersService: UsersService) {}
|
||||
|
||||
async canActivate(context: ExecutionContext) {
|
||||
const req = context.switchToHttp().getRequest();
|
||||
req.user = {
|
||||
userName: 'hardcoded',
|
||||
};
|
||||
if (!this.user) {
|
||||
this.user = await this.usersService.createUser('hardcoded', 'Testy');
|
||||
}
|
||||
req.user = this.user;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue