From 8a45389d0d3d2ff0c19908a695f70a4e4fa86c88 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Sat, 18 Sep 2021 18:57:55 +0300 Subject: [PATCH] feat: cookie maxAge increase & added search param to users fetch --- app/Repositories/UserRepository.ts | 9 ++++++++- config/app.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Repositories/UserRepository.ts b/app/Repositories/UserRepository.ts index 8d70a41..8183deb 100644 --- a/app/Repositories/UserRepository.ts +++ b/app/Repositories/UserRepository.ts @@ -64,10 +64,17 @@ export default class UserRepository { * @returns Array of users */ public async getAll(params?: any) { - const { email, login, first_name, last_name, role, page = 1, limit = 10 }: any = params || {}; + const { search, email, login, first_name, last_name, role, page = 1, limit = 10 }: any = params || {}; const query = this.User.query(); + if (search) { + query + .where('first_name', 'ilike', `%${search}%`) + .orWhere('last_name', 'ilike', `%${search}%`) + .orWhere('email', 'ilike', `%${search}%`); + } + if (email) { query.preload('contacts').whereHas('contacts', q => q.where('email', 'like', `%${email}%`)); } diff --git a/config/app.ts b/config/app.ts index 63a2f08..650224d 100644 --- a/config/app.ts +++ b/config/app.ts @@ -104,7 +104,7 @@ export const http: ServerConfig = { cookie: { domain: '', path: '/', - maxAge: '2h', + maxAge: '1d', httpOnly: true, secure: false, sameSite: false,