Browse Source

add an example lua module for user store

master
Adrian Malacoda 2 years ago
parent
commit
730048ec80
2 changed files with 40 additions and 8 deletions
  1. + 36
    - 0
      lua/test.lua
  2. + 4
    - 8
      who-server-2.toml

+ 36
- 0
lua/test.lua

@ -0,0 +1,36 @@
local test = {}
local users = {
dennis = {
username = "dennis",
password = "5starman!"
},
frank = {
username = "frank",
password = "egg"
},
mac = {
username = "mac",
password = "fight!milk"
},
charlie = {
username = "charlie",
password = "nitekrollers"
},
dee = {
username = "dee",
password = "bird"
}
}
function test.get_user (username)
return users[username]
end
function test.login (username, password)
local user = test.get_user(username)
if user and user.password == password then
return user
end
end
return test

+ 4
- 8
who-server-2.toml

@ -1,13 +1,9 @@
url = "http://baragaki:8001/"
[web]
port = 8001
address = "0.0.0.0"
[user_store]
type = "memory"
[user_store.users]
dennis = "5starman!"
frank = "egg"
mac = "fight!milk"
charlie = "nitekrollers"
dee = "bird"
type = "lua"
file = "lua/test.lua"

Loading…
Cancel
Save