Compare commits
No commits in common. "2067bb9c5525f45e7021399d9b0b7bceb969f9e1" and "8672ca711227ed31ec327d9aa71421ef07a024a7" have entirely different histories.
2067bb9c55
...
8672ca7112
|
|
@ -20,14 +20,10 @@ export class AuthController {
|
||||||
throw new UnauthorizedException('Пользователь не аутентифицирован');
|
throw new UnauthorizedException('Пользователь не аутентифицирован');
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = req.user as { userId: number; username: string; login?: string; role?: string };
|
const user = req.user as { userId: number; username: string; login?: string };
|
||||||
const userWithoutPassword = {
|
const userWithoutPassword = { ...user };
|
||||||
id: user.userId,
|
|
||||||
login: user.login || user.username,
|
|
||||||
role: user.role
|
|
||||||
};
|
|
||||||
|
|
||||||
this.logger.log(`Аутентифицированный пользователь: ${user.username}, роль: ${user.role}`);
|
this.logger.log(`Аутентифицированный пользователь: ${user.username}`);
|
||||||
return {
|
return {
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
user: userWithoutPassword
|
user: userWithoutPassword
|
||||||
|
|
@ -62,8 +58,7 @@ export class AuthController {
|
||||||
success: true,
|
success: true,
|
||||||
user: {
|
user: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
login: user.login,
|
login: user.login
|
||||||
role: user.role // Добавляем роль в ответ
|
|
||||||
},
|
},
|
||||||
access_token
|
access_token
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,15 @@ export class AuthService {
|
||||||
|
|
||||||
if (user && user.password === password) {
|
if (user && user.password === password) {
|
||||||
const { password, ...result } = user;
|
const { password, ...result } = user;
|
||||||
return {
|
return result;
|
||||||
...result,
|
|
||||||
role: user.role
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(user: any) {
|
async login(user: any) {
|
||||||
const payload = {
|
const payload = {
|
||||||
username: user.login,
|
username: user.login,
|
||||||
sub: user.id,
|
sub: user.id
|
||||||
role: user.role
|
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
access_token: this.jwtService.sign(payload),
|
access_token: this.jwtService.sign(payload),
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,10 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(payload: any) {
|
async validate(payload: any) {
|
||||||
return {
|
return {
|
||||||
userId: payload.sub,
|
userId: payload.sub,
|
||||||
username: payload.username,
|
username: payload.username,
|
||||||
login: payload.username,
|
login: payload.username
|
||||||
role: payload.role
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,4 @@ export class User {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
password: string;
|
password: string;
|
||||||
|
|
||||||
@Column({ default: 'user' })
|
|
||||||
role: 'user' | 'admin';
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,14 +224,11 @@ export class PrometheusService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchAllMetricsWithValues(): Promise<any[]> {
|
async fetchAllMetricsWithValues(): Promise<any[]> {
|
||||||
const metricNames = await this.fetchAllMetrics();
|
const metricNames = await this.fetchAllMetrics();
|
||||||
const zvksMetrics = metricNames.filter(metric => metric.startsWith('zvks'));
|
const promises = metricNames.map(async (metric) => {
|
||||||
|
const data = await this.fetchMetrics(metric);
|
||||||
const promises = zvksMetrics.map(async (metric) => {
|
return { metric, data };
|
||||||
const data = await this.fetchMetrics(metric);
|
});
|
||||||
return { metric, data };
|
return Promise.all(promises);
|
||||||
});
|
}
|
||||||
|
|
||||||
return Promise.all(promises);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue