24 lines
636 B
MySQL
24 lines
636 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `account`.`user_getMysqlRole`(vUserName VARCHAR(255))
|
||
|
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci
|
||
|
DETERMINISTIC
|
||
|
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, c.rolePrefix, ''), r.name) INTO vRole
|
||
|
FROM role r
|
||
|
JOIN user u ON u.role = r.id
|
||
|
JOIN roleConfig c
|
||
|
WHERE u.name = vUserName;
|
||
|
|
||
|
RETURN vRole;
|
||
|
END$$
|
||
|
DELIMITER ;
|