Software /
code /
prosody-modules
Changeset
3433:213679266dcb
mod_http_pep_avatar: Redirect to prepped username
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 06 Jan 2019 10:26:32 +0100 |
parents | 3432:61368aec97d6 |
children | 3434:a6722a35f35e |
files | mod_http_pep_avatar/mod_http_pep_avatar.lua |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_pep_avatar/mod_http_pep_avatar.lua Sun Jan 06 10:24:32 2019 +0100 +++ b/mod_http_pep_avatar/mod_http_pep_avatar.lua Sun Jan 06 10:26:32 2019 +0100 @@ -6,6 +6,7 @@ local um = require "core.usermanager"; local nodeprep = require "util.encodings".stringprep.nodeprep; local base64_decode = require "util.encodings".base64.decode; +local urlencode = require "util.http".urlencode; module:depends("http") module:provides("http", { @@ -14,8 +15,12 @@ local request, response = event.request, event.response; local actor = request.ip; - user = nodeprep(user); - if not user then return 400; end + local prepped = nodeprep(user); + if not prepped then return 400; end + if prepped ~= user then + response.headers.location = module:http_url() .. "/" .. urlencode(prepped); + return 302; + end if not um.user_exists(user, module.host) then return 404; end