Comparison

core/sessionmanager.lua @ 3236:4727b2b0e069

sessionmanager: Moved nodeprep to sessionmanager.make_authenticated.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 11 Jun 2010 20:34:00 +0500
parent 3091:d6a059af2077
child 3239:5ea90ee96022
comparison
equal deleted inserted replaced
3233:8f78e8164032 3236:4727b2b0e069
23 local uuid_generate = require "util.uuid".generate; 23 local uuid_generate = require "util.uuid".generate;
24 local rm_load_roster = require "core.rostermanager".load_roster; 24 local rm_load_roster = require "core.rostermanager".load_roster;
25 local config_get = require "core.configmanager".get; 25 local config_get = require "core.configmanager".get;
26 local nameprep = require "util.encodings".stringprep.nameprep; 26 local nameprep = require "util.encodings".stringprep.nameprep;
27 local resourceprep = require "util.encodings".stringprep.resourceprep; 27 local resourceprep = require "util.encodings".stringprep.resourceprep;
28 local nodeprep = require "util.encodings".stringprep.nodeprep;
28 29
29 local fire_event = require "core.eventmanager".fire_event; 30 local fire_event = require "core.eventmanager".fire_event;
30 local add_task = require "util.timer".add_task; 31 local add_task = require "util.timer".add_task;
31 local gettime = require "socket".gettime; 32 local gettime = require "socket".gettime;
32 33
107 108
108 retire_session(session); 109 retire_session(session);
109 end 110 end
110 111
111 function make_authenticated(session, username) 112 function make_authenticated(session, username)
113 username = nodeprep(username);
114 if not username and #username > 0 then return nil, "Invalid username"; end
112 session.username = username; 115 session.username = username;
113 if session.type == "c2s_unauthed" then 116 if session.type == "c2s_unauthed" then
114 session.type = "c2s"; 117 session.type = "c2s";
115 end 118 end
116 session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)"); 119 session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)");