23 lines
595 B
SQL
23 lines
595 B
SQL
DROP FUNCTION IF EXISTS account.user_getMysqlRole;
|
|
|
|
DELIMITER $$
|
|
CREATE DEFINER=`root`@`%` FUNCTION `account`.`user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8
|
|
BEGIN
|
|
/**
|
|
* From a username, it returns the associated MySQL wich should be used when
|
|
* using external authentication systems.
|
|
*
|
|
* @param vUserName The user name
|
|
* @return The associated MySQL role
|
|
*/
|
|
DECLARE vRole VARCHAR(255);
|
|
|
|
SELECT CONCAT(IF(r.hasLogin, 'z-', ''), r.name) INTO vRole
|
|
FROM role r
|
|
JOIN user u ON u.role = r.id
|
|
WHERE u.name = vUserName;
|
|
|
|
RETURN vRole;
|
|
END$$
|
|
DELIMITER ;
|