* fix: event-types input service transform length property * feat: create organizations event-types controller, service and repository * feat: enable organizations event types * fix: create team request user isOrgAdmin check * refactor: hosts array required in team input and output * chore: use platform-libraries at version 0.0.19 * tests: test organizations event-types * feat: enable managed event-types * chore: fix main merge into this branch * feat: assign all team members for managed event-types * refactor: gathering managed event-type users ids * chore: include assignAllTeamMembers in team event response * test: assign all team members db event * chore: delete unused files * docs: swagger create and update request body objects * revert: event-types platform-libraries update * refactor: organisations event-types endpoints accessible by TEAM_ADMIN and up * fix: managed event types output hosts array empty * fix: dont allow creating event-type for non-team member * chore: delete unused variables * tests: negative tests * chore: finish main merge
26 lines
812 B
TypeScript
26 lines
812 B
TypeScript
import { BaseStrategy } from "@/lib/passport/strategies/types";
|
|
import { UsersRepository } from "@/modules/users/users.repository";
|
|
import { Injectable } from "@nestjs/common";
|
|
import { PassportStrategy } from "@nestjs/passport";
|
|
|
|
@Injectable()
|
|
export class ApiAuthMockStrategy extends PassportStrategy(BaseStrategy, "api-auth") {
|
|
constructor(private readonly email: string, private readonly usersRepository: UsersRepository) {
|
|
super();
|
|
}
|
|
|
|
async authenticate() {
|
|
try {
|
|
const user = await this.usersRepository.findByEmailWithProfile(this.email);
|
|
if (!user) {
|
|
throw new Error("User with the provided ID not found");
|
|
}
|
|
|
|
return this.success(user);
|
|
} catch (error) {
|
|
console.error(error);
|
|
if (error instanceof Error) return this.error(error);
|
|
}
|
|
}
|
|
}
|