コード例 #1
0
def test_is_logged_in(app, client, csrf_token_for):
    client.get(url_for("simplelogin.login"))
    assert not is_logged_in()
    response = client.post(
        url_for("simplelogin.login"),
        data={
            "username": "******",
            "password": "******",
            "csrf_token": csrf_token_for(app),
        },
    )
    assert response.status_code == 302
    assert is_logged_in()
コード例 #2
0
def test_logout(app, client, csrf_token_for):
    client.get(url_for("simplelogin.login"))
    assert not is_logged_in()
    client.post(
        url_for("simplelogin.login"),
        data={
            "username": "******",
            "password": "******",
            "csrf_token": csrf_token_for(app),
        },
    )
    assert is_logged_in()
    client.get(url_for("simplelogin.logout"))
    assert not is_logged_in()
コード例 #3
0
ファイル: views.py プロジェクト: 627376948/FlaskCMSApp
    def get(self, slug, ext=None):
        category, _, item_slug = slug.rpartition('/')
        content = app.db.get_with_content(slug=item_slug,
                                          category_slug=category)

        if not content:
            abort(404)

        content = make_model(content)
        if content.status == 'draft' and not self.is_preview:
            abort(404)

        if self.is_preview and not is_logged_in():
            # access denied
            abort(403)

        context = {
            'category': content.category,
            'author': content.author,
            'content': content,
            content.content_type: content
        }

        self.set_elements_visibility(context, content.content_type)
        self.set_elements_visibility(context, slug)
        self.set_content_var_map(context, content)
        templates = [
            f'custom/{content.content_type}/{normalize_var(slug)}.html',
            f'{content.content_type}.html'
        ]
        return render_template(templates, **context)
コード例 #4
0
ファイル: views.py プロジェクト: AquaBindi/quokka
 def _handle_view(self, *args, **kwargs):  # noqa
     """Admin views requires login"""
     if current_app.config.get('ADMIN_REQUIRES_LOGIN') is True:
         if not is_logged_in():
             return redirect(
                 url_for('simplelogin.login', next="/admin")
             )
コード例 #5
0
ファイル: views.py プロジェクト: abnerpc/quokka
    def get(self, slug, ext=None):
        category, _, item_slug = slug.rpartition('/')
        content = app.db.get_with_content(
            slug=item_slug,
            category_slug=category
        )

        if not content:
            abort(404)

        content = make_model(content)
        if content.status == 'draft' and not self.is_preview:
            abort(404)

        if self.is_preview and not is_logged_in():
            # access denied
            abort(403)

        context = {
            'category': content.category,
            'author': content.author,
            'content': content,
            content.content_type: content
        }

        self.set_elements_visibility(context, content.content_type)
        self.set_elements_visibility(context, slug)
        self.set_content_var_map(context, content)
        templates = [
            f'custom/{content.content_type}/{normalize_var(slug)}.html',
            f'{content.content_type}.html'
        ]
        return render_template(templates, **context)
コード例 #6
0
ファイル: webtool.py プロジェクト: jforseth210/jforseth.tech
def check_if_admin():
    """Check if a given user has admin access.

    Returns:
        bool -- Whether or not the user has admin access.
    """
    return bool(is_logged_in()
                and 'admin' in get_current_access(get_username()))
コード例 #7
0
def campagne():

    if is_logged_in():
        rows = req.selectAll("campagne").fetchall()
        return render_template("Campagne.html", rows=rows)

    else:
        return redirect("/login", code=302)
コード例 #8
0
def BanqueSession():

    if is_logged_in():
        #Selection des campagnes
        rowsCampagne = req.selectAll("campagne").fetchall()

        return render_template("BanqueSession.html", rowsCampagne=rowsCampagne)

    else:
        return redirect("/login", code=302)
コード例 #9
0
ファイル: accounts.py プロジェクト: jforseth210/jforseth.tech
def account(account):
    if is_logged_in() and account == get_username():  # .encode("utf-8"):
        if platform.node() == "backup-server-vm":
            flash(
                "The main jforseth.tech server is experiencing issues. Account changes have been suspended."
            )
        account = get_account(get_username())  # .encode("utf-8"))
        groups = account["prayer_groups"].split("|")
        return render_template("accounts/account.html", groups=groups)
    return render_template("errors/403.html"), 403
コード例 #10
0
def banque():
    if is_logged_in():
        #Selection des campagnes
        rowsCampagne = req.selectAll("campagne").fetchall()
        #Selection des chemin
        rowsChemin = req.selectAll("Chemin").fetchall()
        #Selection des sessions
        rowsSession = req.selectAll("Session").fetchall()

        return render_template("Banque.html",
                               rowsCampagne=rowsCampagne,
                               rowsChemin=rowsChemin,
                               rowsSession=rowsSession)

    else:
        return redirect("/login", code=302)
コード例 #11
0
def upload_file():

    if is_logged_in():

        form = FormCampagne(request.form)
        if request.method == 'POST':

            # check if the post request has the file part
            if 'file' not in request.files:
                flash('No file part')
                return redirect(request.url)
            file = request.files['file']

            # if user does not select file, browser also
            # submit a empty part without filename
            if file.filename == '':
                flash('No selected file')
                return redirect(request.url)

            #Si tout se passe bien : Alors on upload le fichier, et on peuple la base de donnée
            if file and allowed_file(file.filename):

                if form.nom.data not in req.selectFromTable(
                        "nom", "campagne").fetchall():

                    #Le nom du fichier est identifiant aleatoire
                    filename = binascii.hexlify(os.urandom(16))

                    #Si les repertoires n'existent pas alors il sont créés
                    if not os.path.exists(UPLOAD_FOLDER + "/ExcelFile"):
                        os.makedirs(UPLOAD_FOLDER + "/ExcelFile")

                    req.insertIntoCampagne(
                        form.nom.data,
                        os.path.join(UPLOAD_FOLDER + "/ExcelFile", filename),
                        form.countdown.data, form.form1.data, form.form2.data)
                    file.save(
                        os.path.join(UPLOAD_FOLDER + "/ExcelFile", filename))

                    return redirect("/Campagne", code=302)

    else:
        return redirect("/login", code=302)

    return render_template("CreationDeCampagne.html", form=form)
コード例 #12
0
ファイル: web.py プロジェクト: mercuree/yt-telegram-archiver
    def index(self):
        if not is_logged_in('admin'):
            return redirect(url_for('simplelogin.login', next=request.url))

        result = None
        if request.method == 'POST':

            url = request.form.get('url')
            if url:
                download_and_send(url)
                result = 'In proccess'
            else:
                result = 'url not set'

            session['result'] = result
            return redirect(url_for('upload_from_url.index'))
        elif request.method == 'GET':
            result = session.pop('result', None)

        return self.render('upload_from_url.html', result=result)
コード例 #13
0
ファイル: web.py プロジェクト: mercuree/yt-telegram-archiver
 def is_accessible(self):
     return is_logged_in('admin')
コード例 #14
0
ファイル: web.py プロジェクト: mercuree/yt-telegram-archiver
 def index(self):
     if not is_logged_in('admin'):
         return redirect(url_for('simplelogin.login', next=request.url))
     return super(MyAdminIndexView, self).index()
コード例 #15
0
 def _handle_view(self, *args, **kwargs):  # noqa
     """Admin views requires login"""
     if current_app.config.get('ADMIN_REQUIRES_LOGIN') is True:
         if not is_logged_in():
             return redirect(url_for('simplelogin.login', next="/admin"))