25 lines
629 B
Lua
25 lines
629 B
Lua
local db = sqlite("dk")
|
|
|
|
local username = string.trim(ctx.form.username)
|
|
if username == "" or db:exists("users", "username = :u", {u = username}) then
|
|
return "username required and must be unique"
|
|
end
|
|
|
|
local email = string.trim(ctx.form.email)
|
|
if util.sanitize_email(email) == "" or db:exists("users", "email = :e", {e = email}) then
|
|
return "email required, must be valid format, and must be unique"
|
|
end
|
|
|
|
if ctx.form.password == "" then
|
|
return "password required"
|
|
end
|
|
|
|
db:insert("users", {
|
|
username = username,
|
|
email = email,
|
|
password = password.hash(ctx.form.password),
|
|
attributes_id = 0
|
|
})
|
|
|
|
return "Account registered!"
|