From 178fa948803176524c03826b4278d697291004e0 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 26 Oct 2024 23:56:12 +0530 Subject: [PATCH] Update user login time on password login. --- queries.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/queries.sql b/queries.sql index 611299199..caf4a5765 100644 --- a/queries.sql +++ b/queries.sql @@ -1180,10 +1180,11 @@ SELECT username, password FROM users WHERE status='enabled' AND type='api'; -- name: login-user WITH u AS ( SELECT users.*, r.name as role_name, r.permissions FROM users - LEFT JOIN roles r ON (r.id = users.user_role_id) - WHERE username=$1 AND status != 'disabled' AND password_login = TRUE + LEFT JOIN roles r ON (r.id = users.user_role_id) + WHERE username = $1 AND status != 'disabled' AND password_login = TRUE + AND CRYPT($2, password) = password ) -SELECT * FROM u WHERE CRYPT($2, password) = password; +UPDATE users SET loggedin_at = NOW() WHERE id = (SELECT id FROM u) RETURNING *; -- name: update-user-profile UPDATE users SET name=$2, email=(CASE WHEN password_login THEN $3 ELSE email END),