LOC-2 Implemented password generation when inviting users
LOC-2 Implemented password generation when inviting users

Now, when a user is invited into a room the inviting user will be given output detailing how the invited user should join

User ben2 may now join room
To join the room, they should do /join BenTest7 0JF6LXE4Q23TFE7A:U2SNQORSY9NZWV7T ben2

That will obviously need to be communicated to the invited user securely, but there's already a need to securely communicate how to connect to the LocalChat instance anway, so it's effectively an extension of an existing need to do a key-exchange.

--- a/client/LocalChatClient.py
+++ b/client/LocalChatClient.py
@@ -259,9 +259,14 @@
         #TODO - Authentication
         '''
         
+        
+        # Generate a password for the new user
+        passw = self.genpassw()
+        
         payload = {"roomName": self.room, 
                    "user": self.user,
-                   "invite": user
+                   "invite": user,
+                   "pass": passw
                    }
         
         request = {"action":"inviteUser",
@@ -273,7 +278,7 @@
         if resp == "BROKENLINK" or resp['status'] != "ok":
             return False
         
-        return True
+        return [self.room,self.roompass,passw,user]
 
 
 
@@ -487,6 +492,7 @@
                     
                     global c
                     c.output('User %s may now join room' %(args[1],))
+                    c.output('To join the room, they should do /join %s %s:%s %s' %(n[0],n[1],n[2],n[3]))
                     return                                        
                     
 

--- a/server/LocalChat.py
+++ b/server/LocalChat.py
@@ -289,7 +289,7 @@
         passhash = bcrypt.hashpw(reqjson['payload']['pass'].encode('utf-8'),bcrypt.gensalt())
         
         # Otherwise, link the user in
-        self.cursor.execute("INSERT INTO users (username,room) values (?,?,?)",(reqjson['payload']['invite'],room,passhash))
+        self.cursor.execute("INSERT INTO users (username,room,passhash) values (?,?,?)",(reqjson['payload']['invite'],room,passhash))
         
         # Push a notification into the group
         m = {