28 lines
684 B
MySQL
28 lines
684 B
MySQL
|
DROP PROCEDURE IF EXISTS account.user_changePassword;
|
||
|
|
||
|
DELIMITER $$
|
||
|
CREATE DEFINER=`root`@`%` PROCEDURE account.user_changePassword(vSelf INT, vOldPassword VARCHAR(255), vPassword VARCHAR(255))
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Changes the user password.
|
||
|
*
|
||
|
* @param vSelf The user id
|
||
|
* @param vOldPassword The current password
|
||
|
* @param vPassword The new password
|
||
|
*/
|
||
|
DECLARE vPasswordOk BOOL;
|
||
|
DECLARE vUserName VARCHAR(255);
|
||
|
|
||
|
SELECT `password` = MD5(vOldPassword), `name`
|
||
|
INTO vPasswordOk, vUserName
|
||
|
FROM user WHERE id = vSelf;
|
||
|
|
||
|
IF NOT vPasswordOk THEN
|
||
|
SIGNAL SQLSTATE '45000'
|
||
|
SET MESSAGE_TEXT = 'Invalid password';
|
||
|
END IF;
|
||
|
|
||
|
CALL user_setPassword(vSelf, vPassword);
|
||
|
END$$
|
||
|
DELIMITER ;
|