mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 21:57:45 +03:00
mod_tokenauth: Return error instead of session for token without role
Such a session triggers errors in module:may or other places since it is generally expected that a session must have a role.
This commit is contained in:
parent
2b25fcb732
commit
98d5a50eb6
1 changed files with 3 additions and 1 deletions
|
@ -252,12 +252,14 @@ function get_token_session(token, resource)
|
|||
local token_info, err = _get_validated_token_info(token_id, token_user, token_host, token_secret);
|
||||
if not token_info then return nil, err; end
|
||||
|
||||
local role = select_role(token_user, token_host, token_info.role);
|
||||
if not role then return nil, "not-authorized"; end
|
||||
return {
|
||||
username = token_user;
|
||||
host = token_host;
|
||||
resource = token_info.resource or resource or generate_identifier();
|
||||
|
||||
role = select_role(token_user, token_host, token_info.role);
|
||||
role = role;
|
||||
};
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue