Commit bdbcf7e0 authored by nanahira's avatar nanahira

update deckbuf permission

parent 8f6f9ccf
Pipeline #37709 passed with stages
in 4 minutes and 51 seconds
......@@ -24,16 +24,34 @@ export class ParticipantService extends CrudService(Participant, {
super(repo);
}
getParticipant(id: number, user: MycardUser) {
return this.findOne(id, (qb) =>
wipeDeckbuf(
user: MycardUser | number,
participant: Participant,
_tournament?: Tournament,
) {
const tournament = _tournament || participant.tournament;
if (!tournament) return;
try {
tournament.checkPermission(user);
} catch (e) {
participant.deckbuf = undefined;
}
}
async getParticipant(id: number, user: MycardUser) {
const res = await this.findOne(id, (qb) =>
Tournament.extraQueryForUser(user, qb, 'tournament'),
);
this.wipeDeckbuf(user, res.data);
return res;
}
getParticipants(dto: Partial<Participant>, user: MycardUser) {
return this.findAll(dto, (qb) =>
async getParticipants(dto: Partial<Participant>, user: MycardUser) {
const res = await this.findAll(dto, (qb) =>
Tournament.extraQueryForUser(user, qb, 'tournament'),
);
res.data?.forEach((p) => this.wipeDeckbuf(user, p));
return res;
}
async createParticipant(dto: Participant, user: MycardUser) {
......
......@@ -23,6 +23,7 @@ export class SrvproService {
tournamentId,
userId,
);
res.data?.checkPermission(userId);
return new SRVProTournamentDto(res.data);
}
......
......@@ -68,14 +68,23 @@ export class TournamentService extends CrudService(Tournament, {
const result = await this.findOne(id, (qb) =>
Tournament.extraQueryForUser(user, qb, this.entityAliasName),
);
result.data?.participants?.forEach((p) =>
this.participantService.wipeDeckbuf(user, p, result.data),
);
result.data?.analytics();
return result;
}
getTournaments(dto: Partial<Tournament>, user: MycardUser | number) {
return this.findAll(dto, (qb) =>
async getTournaments(dto: Partial<Tournament>, user: MycardUser | number) {
const res = await this.findAll(dto, (qb) =>
Tournament.extraQueryForUser(user, qb, this.entityAliasName),
);
res.data?.forEach((t) =>
t.participants?.forEach((p) =>
this.participantService.wipeDeckbuf(user, p, t),
),
);
return res;
}
createTournament(tournament: Tournament, user: MycardUser | number) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment