Update user chip during fetch routine

This commit is contained in:
Jeremy Zhang 2017-04-04 19:16:21 +00:00
parent a95cf3591b
commit 2647021bf7
3 changed files with 21 additions and 4 deletions

View File

@ -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'],

View File

@ -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();

View File

@ -79,7 +79,7 @@
</div>
<div class="row">
<div class="col s1 m4">
<a id="discordlogin_btn" href="{{ url_for("embed.login_discord", _external=True) }}" class="waves-effect waves-light btn-large" target="_blank">Login with Discord</a>
<a id="discordlogin_btn" href="{{ url_for("embed.login_discord", _external=True) }}" class="waves-effect waves-light btn-large" target="_blank">Discord Login</a>
</div>
{% if unauth_enabled %}
<div class="col s1 m8">
@ -95,8 +95,8 @@
<footer class="footer">
<div class="footercontainer">
<div class="currentuserchip left" id="nameplate">
<div class="left"><img src="https://cdn.discordapp.com/icons/213459805048668160/14aa7c0ad94e3c80d2eeef3a83cae1c1.jpg" class="circle left currentuserimage"></div>
<div class="currentusername left">EndenDragon#4151</div>
<div class="left"><img id="currentuserimage" src="https://cdn.discordapp.com/icons/213459805048668160/14aa7c0ad94e3c80d2eeef3a83cae1c1.jpg" class="circle left currentuserimage" style="display: none;"></div>
<div id="currentusername" class="currentusername left">Titan#0001</div>
</div>
<div id="messageboxouter" class="input-field inline"><textarea placeholder="Enter message" id="messagebox" type="text" class="materialize-textarea"></textarea></div>
</div>