LOC-5 - Prevent SYSTEM from joining rooms, and warn if users try to invite it
LOC-5 - Prevent SYSTEM from joining rooms, and warn if users try to invite it

We prevent anyone from joining with the name SYSTEM, and warn the entire room if someone tries to authorise SYSTEM to log in (because they're almost certainly up to no good)

--- a/server/LocalChat.py
+++ b/server/LocalChat.py
@@ -217,6 +217,18 @@
         
         if not self.validateUser(reqjson['payload']):
             return 403
+        
+        
+        if reqjson['payload']['invite'] == "SYSTEM":
+            # Push a notification into the group
+            m = {
+                    "user":"SYSTEM",
+                    "text":"ALERT: User %s tried to invite SYSTEM" % (reqjson['payload']['user'])
+                }
+            self.cursor.execute("INSERT INTO messages (ts,room,msg) VALUES (?,?,?)",(time.time(),room,json.dumps(m))) 
+            self.conn.commit()
+            return 403
+       
         
         
         # Otherwise, link the user in
@@ -301,6 +313,9 @@
             return 400
         
         
+        if reqjson["payload"]["user"] == "SYSTEM":
+            return 403
+        
         # Check whether that user is authorised to connect to that room
         self.cursor.execute("SELECT username, room from users where username=? and room=?",(reqjson['payload']['user'],room))
         r = self.cursor.fetchone()