Compare commits

..

No commits in common. "8466aa1f93e7c6e5efa1cd57df5dbac030c6d333" and "8abfff99e022d9292555beab186c627ed01db236" have entirely different histories.

5 changed files with 18 additions and 34 deletions

View File

@ -20,14 +20,10 @@ export class AuthController {
throw new UnauthorizedException('Пользователь не аутентифицирован');
}
const user = req.user as { userId: number; username: string; login?: string; role?: string };
const userWithoutPassword = {
id: user.userId,
login: user.login || user.username,
role: user.role
};
const user = req.user as { userId: number; username: string; login?: string };
const userWithoutPassword = { ...user };
this.logger.log(`Аутентифицированный пользователь: ${user.username}, роль: ${user.role}`);
this.logger.log(`Аутентифицированный пользователь: ${user.username}`);
return {
isAuthenticated: true,
user: userWithoutPassword
@ -62,8 +58,7 @@ export class AuthController {
success: true,
user: {
id: user.id,
login: user.login,
role: user.role // Добавляем роль в ответ
login: user.login
},
access_token
};

View File

@ -17,19 +17,15 @@ export class AuthService {
if (user && user.password === password) {
const { password, ...result } = user;
return {
...result,
role: user.role
};
return result;
}
return null;
}
async login(user: any) {
const payload = {
username: user.login,
sub: user.id,
role: user.role
const payload = {
username: user.login,
sub: user.id
};
return {
access_token: this.jwtService.sign(payload),

View File

@ -19,11 +19,10 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
}
async validate(payload: any) {
return {
userId: payload.sub,
return {
userId: payload.sub,
username: payload.username,
login: payload.username,
role: payload.role
login: payload.username
};
}
}

View File

@ -10,7 +10,4 @@ export class User {
@Column()
password: string;
@Column({ default: 'user' })
role: 'user' | 'admin';
}

View File

@ -224,14 +224,11 @@ export class PrometheusService {
}
async fetchAllMetricsWithValues(): Promise<any[]> {
const metricNames = await this.fetchAllMetrics();
const zvksMetrics = metricNames.filter(metric => metric.startsWith('zvks'));
const promises = zvksMetrics.map(async (metric) => {
const data = await this.fetchMetrics(metric);
return { metric, data };
});
return Promise.all(promises);
}
const metricNames = await this.fetchAllMetrics();
const promises = metricNames.map(async (metric) => {
const data = await this.fetchMetrics(metric);
return { metric, data };
});
return Promise.all(promises);
}
}