diff --git a/titanembeds/blueprints/api/api.py b/titanembeds/blueprints/api/api.py index 531a2a1..de3c3b1 100644 --- a/titanembeds/blueprints/api/api.py +++ b/titanembeds/blueprints/api/api.py @@ -53,10 +53,13 @@ def update_user_status(guild_id, username, user_key=None): if user_unauthenticated(): ip_address = get_client_ipaddr() status = { + 'authenticated': False, + 'avatar': None, 'ip_address': ip_address, 'username': username, 'user_key': user_key, 'guild_id': guild_id, + 'user_id': session['user_id'], 'banned': checkUserBanned(guild_id, ip_address), 'revoked': checkUserRevoke(guild_id, user_key), } @@ -70,6 +73,8 @@ def update_user_status(guild_id, username, user_key=None): db.session.commit() else: status = { + 'authenticated': True, + 'avatar': session["avatar"], 'username': username, 'guild_id': guild_id, 'user_id': session['user_id'], diff --git a/titanembeds/static/js/embed.js b/titanembeds/static/js/embed.js index b3a2664..af05e24 100644 --- a/titanembeds/static/js/embed.js +++ b/titanembeds/static/js/embed.js @@ -183,7 +183,8 @@ function run_fetch_routine() { var fet = fetch(channel_id); fet.done(function(data) { console.log(data); - + var status = data.status; + update_embed_userchip(status.authenticated, status.avatar, status.username, status.user_id); var guild = query_guild(); guild.done(function(guildobj) { fill_channels(guildobj.channels); @@ -206,6 +207,17 @@ function run_fetch_routine() { }); } +function update_embed_userchip(authenticated, avatar, username, userid) { + if (authenticated) { + $("#currentuserimage").show(); + $("#currentuserimage").attr("src", avatar); + $("#currentusername").text(username); + } else { + $("#currentuserimage").hide(); + $("#currentusername").text(username + "#" + userid); + } +} + $("#discordlogin_btn").click(function() { lock_login_fields(); wait_for_discord_login(); diff --git a/titanembeds/templates/embed.html.j2 b/titanembeds/templates/embed.html.j2 index 6b9c2d4..df09bd7 100644 --- a/titanembeds/templates/embed.html.j2 +++ b/titanembeds/templates/embed.html.j2 @@ -79,7 +79,7 @@