From d444e4b9c3471c7cfb17b508fd26574e7ea7e8aa Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:13:38 -0400
Subject: [PATCH 1/8] orbit: init db: users: provide default for LFX field

Since we are moving away from this system of sharing resources
a good place to start is to provide a default of false for lfx so
that more places can avoid refering to it.
---
 orbit/init-db.sql | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index d26c47b1..de7f6199 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -4,7 +4,7 @@ CREATE TABLE users (
 	id integer primary key,
 	username string UNIQUE NOT NULL,
 	pwdhash string NOT NULL,
-	lfx boolean NOT NULL,
+	lfx boolean NOT NULL DEFAULT FALSE,
 	student_id integer);
 CREATE TABLE sessions (
         token string PRIMARY KEY,

From 9dc1650391f5d68234c88b571b7c59ce55b44d33 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:15:31 -0400
Subject: [PATCH 2/8] orbit: db/hyperspace: use default lfx value

To make the query simpler, since lfx was always being set to 0
(False) and the default is false, it does not need to be specified.
---
 orbit/db.py         | 4 ++--
 orbit/hyperspace.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index e5f414a2..a4a96cab 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -92,8 +92,8 @@ def usr_pwdhashfor_username(usn): return _get(USR_PWDHASHFOR_USERNAME, usn)
 
 
 USR_INS = """
-INSERT INTO users (username, pwdhash, lfx, student_id)
-VALUES (?, ?, ?, ?);
+INSERT INTO users (username, pwdhash, student_id)
+VALUES (?, ?, ?);
 """.strip()
 def usr_ins(usr): return _set(USR_INS, usr)
 
diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py
index c0835c6a..359f7725 100755
--- a/orbit/hyperspace.py
+++ b/orbit/hyperspace.py
@@ -140,7 +140,7 @@ def do_newuser(args):
         errx(f'cannot create duplicate user "{args.username}"')
     else:
         db.usr_ins((args.username, do_bcrypt_hash(args, get=True),
-                    0, args.studentid or 0))
+                    args.studentid or 0))
     if args.studentid:
         db.reg_ins((args.username, args.password, args.studentid))
     do_validate_creds(args)

From 0d49d4062be57501adc8e7973e7846828485c098 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 13:56:40 -0400
Subject: [PATCH 3/8] orbit: db: Remove query to check LFX status of a student

since 326c3d6 ("orbit: remove cruft related to lfx from mail_auth")
we have not needed this database query.
---
 orbit/db.py | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index a4a96cab..96f63c5f 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -145,14 +145,6 @@ def usr_set_lfx(usn): return _set(USR_SET_LFX, usn)
 def usr_set_nolfx(usn): return _set(USR_SET_NOLFX, usn)
 
 
-USR_GETIF_LFX_USERNAME = """
-SELECT lfx
-FROM users
-WHERE username = ?;
-""".strip()
-def usr_getif_lfx_username(usn): return _get(USR_GETIF_LFX_USERNAME, usn)
-
-
 # registration table inferface
 
 REG_INS = """

From 59a626abe1fe567eac67e0f60b143cad5fbbc4c8 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 13:52:02 -0400
Subject: [PATCH 4/8] orbit: hyperspace: remove ability to edit student lfx
 status

since we are no longer querying the LFX status of students as part
of the mail auth flow, the ability to change LFX status with the -x
and -y options in hyperspace are uneeded.
---
 orbit/hyperspace.py | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py
index 359f7725..ad322bf0 100755
--- a/orbit/hyperspace.py
+++ b/orbit/hyperspace.py
@@ -209,12 +209,6 @@ def hyperspace_main(raw_args):
     actions.add_argument('-l', '--listsessions', action='store_const',
                          help='List of all known sessions (some could be invalid)',  # NOQA: E501
                          dest='do', const=do_list_sessions)
-    actions.add_argument('-x', '--lfxenable', action='store_const',
-                         help='Set supplied username lfx status to true',
-                         dest='do', const=do_set_lfx)
-    actions.add_argument('-y', '--lfxdisable', action='store_const',
-                         help='Set supplied username lfx status to false',
-                         dest='do', const=do_set_nolfx)
     actions.add_argument('-q', '--queryuser', action='store_const',
                          help='Get information about supplied username if valid',  # NOQA: E501
                          dest='do', const=do_query_username)

From 92b3ccf5d0e9f874fa56b4f0119dbfe44a235a01 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:02:14 -0400
Subject: [PATCH 5/8] orbit: hyperspace: remove do_set_{no,}lfx helpers

since the -x and -y options are no longer calling these functions,
they are unused.
---
 orbit/hyperspace.py | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py
index ad322bf0..e659a73f 100755
--- a/orbit/hyperspace.py
+++ b/orbit/hyperspace.py
@@ -46,26 +46,6 @@ def do_query_username(args):
     print(USR_FMT.format(*u))
 
 
-def do_set_lfx(args):
-    need(args, u=True)
-
-    if db.usr_getby_username(args.username)[0]:
-        db.usr_set_lfx(args.username)
-    else:
-        nou(args.username)
-    do_query_username(args)
-
-
-def do_set_nolfx(args):
-    need(args, u=True)
-
-    if db.usr_getby_username(args.username)[0]:
-        db.usr_set_nolfx(args.username)
-    else:
-        nou(args.username)
-    do_query_username(args)
-
-
 def do_validate_token(args):
     need(args, t=True)
 

From b8704f93a9ab9109e84e1c9ff0b70d8384a197f4 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:05:25 -0400
Subject: [PATCH 6/8] orbit: db: remove usr_set_{no,}lfx helper

Since there are no callers for these functions, they (and their
associated queries) are no longer needed
---
 orbit/db.py | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index 96f63c5f..39dc32a3 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -129,22 +129,6 @@ def usr_get(): return _get(USR_GET)
 def usr_getby_username(usn): return _get(USR_GETBY_USERNAME, usn)
 
 
-USR_SET_LFX = """
-UPDATE users
-SET lfx = True
-WHERE username = ?;
-""".strip()
-def usr_set_lfx(usn): return _set(USR_SET_LFX, usn)
-
-
-USR_SET_NOLFX = """
-UPDATE users
-SET lfx = False
-WHERE username = ?;
-""".strip()
-def usr_set_nolfx(usn): return _set(USR_SET_NOLFX, usn)
-
-
 # registration table inferface
 
 REG_INS = """

From e5d96ac54cc904759a2c23fd742aac2a82b6d4cb Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:19:42 -0400
Subject: [PATCH 7/8] orbit: db/hyperspace: do not print lfx status

since lfx is always false and can no longer be printed, it does
not need to be displayed when viewing the student roster.
---
 orbit/db.py         | 4 ++--
 orbit/hyperspace.py | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index 39dc32a3..c23f08ae 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -115,14 +115,14 @@ def usr_setpwdhash_username(usr): return _set(USR_SETPWDHASH_USERNAME, usr)
 
 
 USR_GET = """
-SELECT id, username, pwdhash, lfx, student_id
+SELECT id, username, pwdhash, student_id
 FROM users;
 """.strip()
 def usr_get(): return _get(USR_GET)
 
 
 USR_GETBY_USERNAME = """
-SELECT id, username, pwdhash, lfx, student_id
+SELECT id, username, pwdhash, student_id
 FROM users
 WHERE username = ?;
 """.strip()
diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py
index e659a73f..f4706648 100755
--- a/orbit/hyperspace.py
+++ b/orbit/hyperspace.py
@@ -33,7 +33,6 @@ def nou(u):
 Orbit ID        : {}
 Username        : {}
 Hashed Password : {}
-LFX enabled     : {}
 Student ID      : {}
 """.strip()
 

From 99a68346e6d87dbceb907e0a952d1c8915193a11 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 24 Mar 2024 14:20:27 -0400
Subject: [PATCH 8/8] orbit: init db: users: remove lfx field

Since there are no references to the lfx field, it does not need
to be stored.
---
 orbit/init-db.sql | 1 -
 1 file changed, 1 deletion(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index de7f6199..8f798740 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -4,7 +4,6 @@ CREATE TABLE users (
 	id integer primary key,
 	username string UNIQUE NOT NULL,
 	pwdhash string NOT NULL,
-	lfx boolean NOT NULL DEFAULT FALSE,
 	student_id integer);
 CREATE TABLE sessions (
         token string PRIMARY KEY,
