示例#1
0
文件: api.py 项目: kfoss/try41
 def new3():
     if not USERS or current_user.is_authenticated():
         exposed_ports = [EXPOSED_PORT5, EXPOSED_PORT4]
         cookie = request.cookies.get(COOKIE)
         if re.match(UUID4, cookie):
             spinup = 1
             # check if this image has already been spun up for this session
             if r.exists(cookie):
                 # !! TODO error check
                 data = r.lrange(cookie, 0, -1)
                 for record in data:
                     jrec = json.loads(record)
                     if jrec['image'] == "lab41/hemlock":
                         if jrec['expired'] == 0:
                             app.logger.info('a hemlock container is already running for this session') 
                             spinup = 0
                             return jsonify(url="wait3")
             if spinup == 1:
                 if SSL:
                     container = c.create_container(IMAGE_NAME3, tty=True, environment={'REMOTE_HOST': RSYSLOG_HOST, 'PARENT_HOST': PARENT_HOST, 'SSL': "True"})
                 else:
                     container = c.create_container(IMAGE_NAME3, tty=True, environment={'REMOTE_HOST': RSYSLOG_HOST, 'PARENT_HOST': PARENT_HOST})
                 container_id = container["Id"]
                 c.start(container, publish_all_ports=True)
                 b = c.inspect_container(container)
                 bad = store_metadata(exposed_ports, container_id, container, IMAGE_NAME3)
                 if bad:
                     return render_template("index.html")
                 else:
                     return jsonify(url="launch")
             else:
                 return jsonify(url="wait3")
     else:
         return jsonify(url="login")
示例#2
0
 def details():
     if not USERS or current_user.is_authenticated():
         url = get_url(request)
         return render_template("details.html",
                                url=url,
                                USERS=USERS,
                                SSL=SSL,
                                DOMAIN=DOMAIN)
     else:
         return jsonify(url="login")
示例#3
0
 def home_page():
     if current_user.is_authenticated():
         return profile_page()
     return render_template_string("""
         {% extends "base.html" %}
         {% block content %}
         <h2>{%trans%}Home Page{%endtrans%}</h2>
         <p><a href="{{ url_for('user.login') }}">{%trans%}Sign in{%endtrans%}</a></p>
         {% endblock %}
         """)
示例#4
0
文件: app.py 项目: P2PTeam/Flask-User
 def home_page():
     if current_user.is_authenticated():
         return profile_page()
     return render_template_string("""
         {% extends "base.html" %}
         {% block content %}
         <h2>{%trans%}Home Page{%endtrans%}</h2>
         <p><a href="{{ url_for('user.login') }}">{%trans%}Sign in{%endtrans%}</a></p>
         {% endblock %}
         """)
示例#5
0
 def new():
     if not USERS or current_user.is_authenticated():
         exposed_ports = [EXPOSED_PORT1]
         cookie = request.cookies.get(COOKIE)
         if re.match(UUID4, cookie):
             spinup = 1
             # check if this image has already been spun up for this session
             if r.exists(cookie):
                 # !! TODO error check
                 data = r.lrange(cookie, 0, -1)
                 for record in data:
                     jrec = json.loads(record)
                     if jrec['image'] == "lab41/gestalt":
                         if jrec['expired'] == 0:
                             app.logger.info(
                                 'a gestalt container is already running for this session'
                             )
                             spinup = 0
                             return jsonify(url="wait")
             if spinup == 1:
                 host_config = c.create_host_config(publish_all_ports=True)
                 if SSL:
                     container = c.create_container(image=IMAGE_NAME1,
                                                    host_config=host_config,
                                                    environment={
                                                        'REMOTE_HOST':
                                                        RSYSLOG_HOST,
                                                        'PARENT_HOST':
                                                        PARENT_HOST,
                                                        'SSL': "True"
                                                    })
                 else:
                     container = c.create_container(image=IMAGE_NAME1,
                                                    host_config=host_config,
                                                    environment={
                                                        'REMOTE_HOST':
                                                        RSYSLOG_HOST,
                                                        'PARENT_HOST':
                                                        PARENT_HOST
                                                    })
                 c.start(container=container.get('Id'))
                 b = c.inspect_container(container)
                 bad = store_metadata(exposed_ports, container.get('Id'),
                                      container, IMAGE_NAME1)
                 if bad:
                     return render_template("index.html")
                 else:
                     return jsonify(url="launch")
             else:
                 return jsonify(url="wait")
     else:
         return jsonify(url="login")
示例#6
0
文件: webrob.py 项目: volnik/docker
def show_user_data():
    if not current_user.is_authenticated():
        return redirect(url_for('user.login'))
    get_user_data(current_user.username)
    print request.host

    
    overlay = None
    if(session.get('show_loading_overlay') == True):
        overlay = True
        
        print "set overlay"
        session.pop('show_loading_overlay')
    
    return render_template('show_user_data.html', overlay=overlay)
示例#7
0
 def home_page():
     return render_template_string("""
         {% extends "base.html" %}
         {% block content %}
             <h2>{%trans%}Home Page{%endtrans%}</h2>
             {% if current_user.is_authenticated() %}
             <p> <a href="{{ url_for('profile_page') }}">
                 {%trans%}Profile Page{%endtrans%}</a></p>
             <p> <a href="{{ url_for('user.logout') }}">
                 {%trans%}Sign out{%endtrans%}</a></p>
             {% else %}
             <p> <a href="{{ url_for('user.login') }}">
                 {%trans%}Sign in or Register{%endtrans%}</a></p>
             {% endif %}
         {% endblock %}
         """)
     if current_user.is_authenticated():
         return redirect(url_for('profile_page'))
     else:
         return redirect(url_for('user.login'))
示例#8
0
 def home_page():
     return render_template_string("""
         {% extends "base.html" %}
         {% block content %}
             <h2>{%trans%}Home Page{%endtrans%}</h2>
             {% if current_user.is_authenticated() %}
             <p> <a href="{{ url_for('profile_page') }}">
                 {%trans%}Profile Page{%endtrans%}</a></p>
             <p> <a href="{{ url_for('user.logout') }}">
                 {%trans%}Sign out{%endtrans%}</a></p>
             {% else %}
             <p> <a href="{{ url_for('user.login') }}">
                 {%trans%}Sign in or Register{%endtrans%}</a></p>
             {% endif %}
         {% endblock %}
         """)
     if current_user.is_authenticated():
         return redirect(url_for('profile_page'))
     else:
         return redirect(url_for('user.login'))
示例#9
0
 def decorated_view(*args, **kwargs):
     id = kwargs['id']
     # get element
     if type == Album:
         element = Album.query.get_or_404(id)
     elif type == Photo:
         element = Photo.query.get_or_404(id)
     elif type == Directory:
         element = Directory.query.get_or_404(id)
         element = element.album
     else:
         return abort(404)
     # user must be logged
     if not current_user.is_authenticated():
         return current_app.user_manager.unauthenticated_view_function()
     # user must be admin or poweruser and author of element
     if not (current_user.has_roles('admin') or
             (current_user.has_roles('poweruser')
              and element.author == current_user)):
         return current_app.user_manager.unauthenticated_view_function()
     return func(*args, **kwargs)
示例#10
0
文件: api.py 项目: kfoss/try41
 def details3():
     if not USERS or current_user.is_authenticated():
         url = get_url(request)
         return render_template("details3.html",url=url, USERS=USERS, SSL=SSL, DOMAIN=DOMAIN)
     else:
         return jsonify(url="login")
示例#11
0
def make_cache_key():
    ''' Replace default cache key prefix with a string that also includes
    query arguments. '''
    return request.path + request.query_string + unicode(current_user.is_authenticated())
示例#12
0
 def home_page():
     if current_user.is_authenticated():
         return redirect(url_for('profile_page'))
     else:
         return redirect(url_for('user.login'))
示例#13
0
 def decorated_view(*args, **kwargs):
     if app.login_manager._login_disabled:
         return func(*args, **kwargs)
     elif not current_user.is_authenticated():
         return jsonify({'redirect': login_url(url_for('user.login'), request.url)})
     return func(*args, **kwargs)
示例#14
0
文件: ui.py 项目: xflicsu/immuno
def patients():
    if current_user.is_authenticated():
        return redirect(url_for('profile'))
    else:
        return redirect(url_for('user.login'))
示例#15
0
def home_page():
    if current_user.is_authenticated():
        return redirect(url_for('subscriptions_page'))
    else:
        return redirect(url_for('user.login'))
示例#16
0
 def index(self):
     if not current_user.is_authenticated():
         return redirect(url_for('user.login'))
     return super(MyAdminIndexView, self).index()
示例#17
0
 def is_accessible(self):
     return current_user.is_authenticated()
示例#18
0
文件: views.py 项目: extant1/ships
 def is_accessible(self):
     if not current_user.is_authenticated():
         return False
     return current_user.has_roles("Admin")
示例#19
0
文件: app.py 项目: JPT580/ddns
 def home_page():
     if current_user.is_authenticated():
         return profile_page()
     return render_template('index.html')
示例#20
0
文件: views.py 项目: extant1/ships
def before_request():
    if current_user.is_authenticated():
        current_user.seen()
示例#21
0
文件: models.py 项目: zacatac/emailer
def icesportsforum_email(form, field):
    if not current_user.is_authenticated() or not current_user.has_roles('management'):
        email = field.data.strip().lower()
        if email == "*****@*****.**": return #***ALERT*** MUST BE REMOVED. FOR TESTING ONLY
        if "@" not in email or email.split("@")[1] != "icesportsforum.com":
            raise ValidationError('Must have an Ice Sports Forum email to register')
示例#22
0
 def home_page():
     if current_user.is_authenticated():
         return profile_page()
     return render_template("index.html")