diff src/lib/User.luan @ 8:be36282b556a

add new_thread
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 29 Jun 2022 00:04:09 -0600
parents fc3ee39d7764
children de0cbf515ef5
line wrap: on
line diff
--- a/src/lib/User.luan	Thu Jun 23 23:38:03 2022 -0600
+++ b/src/lib/User.luan	Wed Jun 29 00:04:09 2022 -0600
@@ -64,6 +64,11 @@
 	return user
 end
 
+function User.get_by_id(id)
+	local doc = Db.get_document("id:"..id)
+	return doc and User.from_doc(doc)
+end
+
 function User.get_by_email(email)
 	local doc = Db.get_document("user_email:"..lucene_quote(email))
 	return doc and from_doc(doc)
@@ -88,6 +93,12 @@
 	return user
 end
 
+function User.current_required()
+	local user = User.current()
+	user or Http.response.send_redirect "/login.html"
+	return user
+end
+
 local password_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 do
 	local t = {}