Exemplo n.º 1
0
 def dashboard(self):
     print("username + password " + username + password)
     serverFunctions.ping(pubkey_hex_str, signing_key, headers)
     print("refresh pinged")
     serverFunctions.report(pubkey_hex_str, headers, "online")
     print("refresh report")
     template = env.get_template('dashboard.html')
     broadcasts = database.get_all_broadcasts()
     return template.render(onlineusers=getUsers(),
                            username=username,
                            recentbroadcasts=broadcasts)
Exemplo n.º 2
0
 def check_privatemessage(self, message):
     serverFunctions.ping(pubkey_hex_str, signing_key, headers)
     if (current_selected_user != None):
         print("current selected user " + current_selected_user)
         message_error = clientFunctions.privatemessage(
             message, signing_key, headers, current_selected_user)
         raise cherrypy.HTTPRedirect('/changeMessagePage?sender_username='******'/changeMessagePage')
Exemplo n.º 3
0
    def privateMessage(self, error="0"):
        global current_onlineusers
        current_onlineusers = clientFunctions.get_onlineusernames(headers)

        serverFunctions.ping(pubkey_hex_str, signing_key, headers)
        serverFunctions.report(pubkey_hex_str, headers, "online")

        template = env.get_template('privatemessage.html')
        return template.render(onlineusers=current_onlineusers,
                               pastmessages="",
                               error=error)
Exemplo n.º 4
0
def authoriseUserLogin(username_given=None, password_given=None):
    print("Log on attempt from {0}:{1}".format(username_given, password_given))

    credentials = ('%s:%s' % (username_given, password_given))
    b64_credentials = base64.b64encode(credentials.encode('ascii'))

    test_headers = {
        'Authorization': 'Basic %s' % b64_credentials.decode('ascii'),
        'Content-Type': 'application/json; charset=utf-8',
    }
    response = serverFunctions.ping(None, signing_key, test_headers)

    print(response)
    if response["authentication"] == 'basic' or response[
            "authentication"] == 'api-key':
        global username
        global password
        username = username_given
        password = password_given

        global signing_key
        signing_key = nacl.signing.SigningKey.generate()
        global pubkey
        pubkey = signing_key.verify_key.encode(
            encoder=nacl.encoding.HexEncoder)
        global pubkey_hex_str
        pubkey_hex_str = pubkey.decode('utf-8')

        global headers
        headers = test_headers

        serverFunctions.add_pubkey(pubkey_hex_str, signing_key, username,
                                   headers)
        serverFunctions.ping(pubkey_hex_str, signing_key, headers)
        serverFunctions.report(pubkey_hex_str, headers, "online")
        serverFunctions.get_loginserver_record(headers)
        clientFunctions.ping_all_online(headers)
        print(pubkey_hex_str)
        #serverFunctions.add_privatedata("Hello",headers,signing_key, "1234")
        #serverFunctions.get_privatedata(headers,signing_key)
        print("Success")
        return 0
    else:
        print("Failure")
        return 1
Exemplo n.º 5
0
    def changeMessagePage(self, sender_username=None, error="0"):
        print("refreshed ping in change pm")
        serverFunctions.ping(pubkey_hex_str, signing_key, headers)
        print("refreshed reprt in change pm")
        serverFunctions.report(pubkey_hex_str, headers, "online")
        global current_selected_user
        current_selected_user = sender_username

        template = env.get_template('privatemessage.html')
        if sender_username != None:
            print(sender_username)
            past_messages_database = database.get_messages_from(
                username, sender_username)
            return template.render(onlineusers=current_onlineusers,
                                   pastmessages=past_messages_database,
                                   currentuser=sender_username,
                                   error=error)
        else:
            return template.render(
                onlineusers=clientFunctions.get_onlineusernames(headers),
                pastmessages="",
                error=error)
Exemplo n.º 6
0
 def check_broadcast(self, message):
     serverFunctions.ping(pubkey_hex_str, signing_key, headers)
     clientFunctions.broadcast(message, signing_key, headers)
     raise cherrypy.HTTPRedirect('/dashboard')