Comparison

core/sessionmanager.lua @ 3240:9782a222e941

Merge 0.7->trunk
author Matthew Wild <mwild1@gmail.com>
date Sat, 12 Jun 2010 02:39:18 +0100
parent 3145:675241be2935
parent 3239:5ea90ee96022
child 3437:1e93b4d46d92
comparison
equal deleted inserted replaced
3235:651139e831b1 3240:9782a222e941
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 initialize_filters = require "util.filters".initialize; 30 local initialize_filters = require "util.filters".initialize;
30 local fire_event = require "core.eventmanager".fire_event; 31 local fire_event = require "core.eventmanager".fire_event;
31 local add_task = require "util.timer".add_task; 32 local add_task = require "util.timer".add_task;
32 local gettime = require "socket".gettime; 33 local gettime = require "socket".gettime;
120 121
121 retire_session(session); 122 retire_session(session);
122 end 123 end
123 124
124 function make_authenticated(session, username) 125 function make_authenticated(session, username)
126 username = nodeprep(username);
127 if not username or #username == 0 then return nil, "Invalid username"; end
125 session.username = username; 128 session.username = username;
126 if session.type == "c2s_unauthed" then 129 if session.type == "c2s_unauthed" then
127 session.type = "c2s"; 130 session.type = "c2s";
128 end 131 end
129 session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)"); 132 session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)");