updated select response
This commit is contained in:
@@ -11,7 +11,7 @@ export class LoginService {
|
||||
private readonly redis: RedisHandlers,
|
||||
private readonly passHandlers: PasswordHandlers,
|
||||
private readonly prisma: PrismaService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async run(dto: userLoginValidator) {
|
||||
const foundUser = await this.prisma.users.findFirstOrThrow({
|
||||
@@ -137,14 +137,16 @@ export class LoginService {
|
||||
});
|
||||
selectList = employees;
|
||||
}
|
||||
|
||||
let fullName = `${foundPerson.firstname}`;
|
||||
if (foundPerson.middle_name) fullName += ` ${foundPerson.middle_name}`;
|
||||
if (foundPerson.birthname) fullName += ` ${foundPerson.birthname}`;
|
||||
fullName += ` ${foundPerson.surname}`;
|
||||
const redisData = AuthTokenSchema.parse({
|
||||
people: foundPerson,
|
||||
users: foundUser,
|
||||
credentials: {
|
||||
person_uu_id: foundPerson.uu_id,
|
||||
person_name: foundPerson.firstname,
|
||||
person_full_name: `${foundPerson.firstname} ${foundPerson.middle_name || ''} | ${foundPerson.birthname || ''} | ${foundPerson.surname}`,
|
||||
uuid: foundPerson.uu_id,
|
||||
fullName: fullName,
|
||||
},
|
||||
selectionList: {
|
||||
type: foundUser.user_type,
|
||||
|
||||
@@ -19,7 +19,7 @@ export class SelectService {
|
||||
constructor(
|
||||
private readonly redis: RedisHandlers,
|
||||
private readonly prisma: PrismaService,
|
||||
) {}
|
||||
) { }
|
||||
async run(dto: userSelectValidator, req: Request) {
|
||||
const accessObject = await this.redis.getLoginFromRedis(req);
|
||||
if (!accessObject) {
|
||||
@@ -196,8 +196,6 @@ export class SelectService {
|
||||
company: company,
|
||||
menu: null,
|
||||
pages: null,
|
||||
config: null,
|
||||
caches: null,
|
||||
selection: await this.prisma.build_living_space.findFirstOrThrow({
|
||||
where: { uu_id: dto.uuid },
|
||||
select: {
|
||||
|
||||
@@ -9,9 +9,8 @@ export type UserType = (typeof UserType)[keyof typeof UserType];
|
||||
|
||||
// Credentials
|
||||
export const CredentialsSchema = z.object({
|
||||
person_uu_id: z.string(),
|
||||
person_name: z.string(),
|
||||
full_name: z.string(),
|
||||
uuid: z.string(),
|
||||
fullName: z.string(),
|
||||
});
|
||||
export type Credentials = z.infer<typeof CredentialsSchema>;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export class RedisHandlers {
|
||||
constructor(
|
||||
private readonly cacheService: CacheService,
|
||||
private readonly passwordService: PasswordHandlers,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Validates that a Redis key follows the expected format
|
||||
@@ -125,7 +125,7 @@ export class RedisHandlers {
|
||||
if (parts[1] === parts[2]) {
|
||||
const value = await this.cacheService.get(key);
|
||||
if (value) {
|
||||
return { key, value };
|
||||
return { key: value.key, value: value.value };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user