From 79d5dd5f0693e7af7213e97a4e8564358a9b6357 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Fri, 29 Nov 2024 19:31:48 -0500 Subject: [PATCH] Implement server_user table --- db/newsgroup.sql | 9 +++++++++ lib/nntp/tiny/user.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 lib/nntp/tiny/user.py diff --git a/db/newsgroup.sql b/db/newsgroup.sql index 98d13e2..0c4c85c 100644 --- a/db/newsgroup.sql +++ b/db/newsgroup.sql @@ -1,5 +1,14 @@ begin transaction; +create server_user ( + id INTEGER PRIMARY KEY NOT NULL, + active BOOLEAN NOT NULL DEFAULT TRUE, + username TEXT NOT NULL, + password TEXT, + fullname TEXT, + mail TEXT NOT NULL +); + create table newsgroup ( id INTEGER PRIMARY KEY NOT NULL, created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/lib/nntp/tiny/user.py b/lib/nntp/tiny/user.py new file mode 100644 index 0000000..7d4c671 --- /dev/null +++ b/lib/nntp/tiny/user.py @@ -0,0 +1,14 @@ +from nntp.tiny.db import DatabaseTable +from nntp.tiny.passwd import compare + +class User(DatabaseTable): + name = 'server_user' + key = 'id' + columns = 'id', 'active', 'username', 'password', 'fullname', 'mail', + + def auth(self, password: str): + if self.active is False or or self.password is None or self.password == '': + return False + + return compare(password, self.password) +