Add prosedure sp_auth_login

This commit is contained in:
Dita Aji Pratama 2025-09-04 16:49:14 +07:00
parent 356d88f73a
commit d6cbd8c782
2 changed files with 19 additions and 2 deletions

View File

@ -256,7 +256,7 @@ class auth:
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles, jwt)
user = user_validation['data']
loggorilla.prcss(APIADDR, "Get dependency data")
self.cursor.execute("SELECT COUNT(*) AS `count`, auth.token, auth_profile.id, auth_profile.username, auth.password FROM auth_profile INNER JOIN auth ON auth.token = auth_profile.token WHERE auth_profile.username = %s ; ", (user['profile']['username'],) )
self.cursor.execute("call sp_auth_login(%s);", (user['profile']['username'],) )
result_login = self.cursor.fetchone()
self.cursor.execute(f"SELECT COUNT(*) AS `count`, auth_profile.token, auth_profile.email FROM auth_profile_verification INNER JOIN auth_profile ON auth_profile.id = auth_profile_verification.profile WHERE auth_profile.email = %s AND auth_profile_verification.type = 'email' ; ", (email,) )
result_email = self.cursor.fetchone()
@ -413,7 +413,7 @@ class auth:
self.cursor.execute("BEGIN;")
try:
loggorilla.prcss(APIADDR, "Get dependency data")
self.cursor.execute("SELECT COUNT(*) AS `count`, auth.token, auth_profile.id, auth_profile.username, auth.password FROM auth_profile INNER JOIN auth ON auth.token = auth_profile.token WHERE auth_profile.username = %s ; ", (username,) )
self.cursor.execute("call sp_auth_login(%s);", (username,) )
result_login = self.cursor.fetchone()
self.cursor.execute("SELECT `profile`, `type`, `verified` FROM auth_profile_verification WHERE `type` = 'email' AND `profile` = %s ; ", (result_login['id'],) )
result_verification = self.cursor.fetchone()

View File

@ -106,3 +106,20 @@ BEGIN
END WHILE;
END //
DELIMITER ;
DELIMITER //
CREATE PROCEDURE sp_auth_login(
IN p_username varchar(36)
)
BEGIN
SELECT
COUNT(*) AS `count`,
auth.token,
auth_profile.id,
auth_profile.username,
auth.password
FROM auth_profile
INNER JOIN auth ON auth.token = auth_profile.token
WHERE auth_profile.username = p_username ;
END //
DELIMITER ;