diff --git a/modules/api/auth.py b/modules/api/auth.py index ae5d82c..67eaeb8 100644 --- a/modules/api/auth.py +++ b/modules/api/auth.py @@ -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() diff --git a/sql/auth.sql b/sql/auth.sql index 9632978..d15f20f 100644 --- a/sql/auth.sql +++ b/sql/auth.sql @@ -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 ;