Skip to content

Commit fa62b7f

Browse files
authored
Remove unnecessary salt row (#17)
* Remove salt parameter from person registration and update procedures * Remove salt parameter from mock person registration calls
1 parent e7f8356 commit fa62b7f

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

database.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ CREATE OR REPLACE TABLE person (
1616
person_name VARCHAR(100) UNIQUE,
1717
email VARCHAR(100) UNIQUE,
1818
hashed_password VARCHAR(100),
19-
salt BINARY(16),
2019
registration_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
2120
last_login TIMESTAMP NULL,
2221
language_id INT NULL,

procedures/auth.sql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ CREATE OR REPLACE PROCEDURE register_person(
77
IN p_name VARCHAR(100),
88
IN p_email VARCHAR(100),
99
IN p_hashed_password VARBINARY(255),
10-
IN p_salt BINARY(16),
1110
IN p_language_iso_code CHAR(2)
1211
)
1312
BEGIN
@@ -39,8 +38,8 @@ BEGIN
3938
WHERE iso_code = p_language_iso_code;
4039

4140
-- Insert the new person into the database
42-
INSERT INTO person (person_name, email, hashed_password, salt, language_id)
43-
VALUES (p_name, p_email, p_hashed_password, p_salt, v_language_id);
41+
INSERT INTO person (person_name, email, hashed_password, language_id)
42+
VALUES (p_name, p_email, p_hashed_password, v_language_id);
4443
END //
4544

4645
CREATE OR REPLACE PROCEDURE login_person(
@@ -50,21 +49,20 @@ CREATE OR REPLACE PROCEDURE login_person(
5049
BEGIN
5150
DECLARE v_person_id INT;
5251
DECLARE v_hashed_password VARCHAR(100);
53-
DECLARE v_salt BINARY(16);
5452

5553
-- Check if the person exists
5654
IF NOT person_exists(p_person_id, p_email) THEN
5755
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'User not found';
5856
END IF;
5957

60-
-- Retrieve the person_id, hashed password, and salt
61-
SELECT person_id, hashed_password, salt
62-
INTO v_person_id, v_hashed_password, v_salt
58+
-- Retrieve the person_id, hashed salted password
59+
SELECT person_id, hashed_password
60+
INTO v_person_id, v_hashed_password
6361
FROM person
6462
WHERE (person_id = p_person_id OR email = p_email);
6563

6664
-- Return the result set
67-
SELECT v_person_id AS person_id, v_hashed_password AS hashed_password, v_salt AS salt;
65+
SELECT v_person_id AS person_id, v_hashed_password AS hashed_password;
6866
END //
6967

7068
CREATE OR REPLACE PROCEDURE login_person_by_id(

procedures/update/person.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ CREATE OR REPLACE PROCEDURE update_person(
1717
IN p_name VARCHAR(100),
1818
IN p_email VARCHAR(100),
1919
IN p_hashed_password VARBINARY(255),
20-
IN p_salt BINARY(16),
2120
IN p_language_iso_code CHAR(2)
2221
)
2322
BEGIN
@@ -59,7 +58,6 @@ BEGIN
5958
person_name = COALESCE(p_name, person_name),
6059
email = COALESCE(p_email, email),
6160
hashed_password = COALESCE(p_hashed_password, hashed_password),
62-
salt = COALESCE(p_salt, salt),
6361
language_id = COALESCE(v_language_id, language_id)
6462
WHERE person_id = p_person_id;
6563
END //

setup/z_mock/person.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
USE smartcooking;
33

44
-- Fill the database with mock data
5-
CALL register_person('John Doe', '[email protected]', 'password', unhex('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6'), 'en');
6-
CALL register_person('Jane Smith', '[email protected]', 'password', unhex('f1e2d3c4b5a6978899aabbccddeeff00'), 'fr');
7-
CALL register_person('Alice Brown', '[email protected]', 'password', unhex('0123456789abcdef0123456789abcdef'), 'es');
8-
CALL register_person('Bob White', '[email protected]', 'password', unhex('fedcba9876543210fedcba9876543210'), 'en');
5+
CALL register_person('John Doe', '[email protected]', 'password', 'en');
6+
CALL register_person('Jane Smith', '[email protected]', 'password', 'fr');
7+
CALL register_person('Alice Brown', '[email protected]', 'password', 'es');
8+
CALL register_person('Bob White', '[email protected]', 'password', 'en');

0 commit comments

Comments
 (0)