Software /
code /
prosody
Annotate
core/usermanager.lua @ 60:44800be871f5
User registration, etc (jabber:iq:register)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 05 Oct 2008 04:55:45 +0500 |
parent | 53:14ea0fe6ca86 |
child | 228:875842235836 |
rev | line source |
---|---|
0 | 1 |
2 require "util.datamanager" | |
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 | 5 |
6 module "usermanager" | |
7 | |
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 | 10 local credentials = datamanager.load(username, host, "accounts") or {}; |
11 if password == credentials.password then return true; end | |
12 return false; | |
13 end | |
38 | 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 | 23 return _M; |