Annotate

core/usermanager.lua @ 146:3826ca244eb6 s2s

working outgoing s2s \o/
author Matthew Wild <mwild1@gmail.com>
date Fri, 24 Oct 2008 03:42:26 +0100
parent 60:44800be871f5
child 228:875842235836
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
1
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
2 require "util.datamanager"
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
3 local datamanager = datamanager;
53
14ea0fe6ca86 Session destruction fixes, some debugging code while we fix the rest. Also change logger to be more useful.
Matthew Wild <mwild1@gmail.com>
parents: 38
diff changeset
4 local log = require "util.logger".init("usermanager");
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
5
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
6 module "usermanager"
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
7
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
8 function validate_credentials(host, username, password)
53
14ea0fe6ca86 Session destruction fixes, some debugging code while we fix the rest. Also change logger to be more useful.
Matthew Wild <mwild1@gmail.com>
parents: 38
diff changeset
9 log("debug", "User '%s' is being validated", username);
0
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
10 local credentials = datamanager.load(username, host, "accounts") or {};
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
11 if password == credentials.password then return true; end
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
12 return false;
3e3171b59028 First commit, where do you want to go tomorrow?
matthew
parents:
diff changeset
13 end
38
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
14
60
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
15 function user_exists(username, host)
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
16 return datamanager.load(username, host, "accounts") ~= nil;
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
17 end
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
18
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
19 function create_user(username, password, host)
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
20 return datamanager.store(username, host, "accounts", {password = password});
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
21 end
44800be871f5 User registration, etc (jabber:iq:register)
Waqas Hussain <waqas20@gmail.com>
parents: 53
diff changeset
22
38
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
23 return _M;