from flask import Blueprint, request, url_for, render_template
from flask.ext.security import current_user

play = Blueprint('play', __name__, template_folder='templates')


@play.route('/')
def index():
    api_token = current_user.api_token
    return render_template('play/index.html', api_token=api_token)

@@ -56,16 +56,43 @@
 emplate%0A
+from flask import redirect%0A
 from fla
@@ -126,16 +126,31 @@
 ent_user
+, AnonymousUser
 %0A%0Aplay =
@@ -239,16 +239,63 @@
 ndex():%0A
+    if hasattr(current_user, 'api_token'):%0A    
     api_
@@ -325,16 +325,20 @@
 i_token%0A
+    
     retu
@@ -396,8 +396,60 @@
 _token)%0A
+    else:%0A        return redirect('/account/login')%0A

Fix error if anonymous user is logged in, instead redirect to login page