Пример #1
0
def login(width=None, height=None):
    # if not width or not height:
    #     return """
    #     <script>
    #     (() => window.location.href = window.location.href +
    #     ['', window.innerWidth, window.innerHeight].join('/'))()
    #     </script>
    #     """
    if current_user.is_authenticated:
        #session["PRIVATE_APPS"]=read_private_apps(current_user.email,app)
        return redirect(url_for('index'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is None or not user.check_password(form.password.data):
            flash('Invalid username or password', "error")
            return redirect(url_for('login'))
        login_user(user, remember=form.remember_me.data)
        session.permanent = form.remember_me.data
        next_page = request.args.get('next')
        #session["APPS"]=FREEAPPS
        user.user_apps = FREEAPPS + read_private_apps(current_user.email, app)
        db.session.add(user)
        db.session.commit()
        # session["width"]=width
        # session["height"]=height
        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('index')
        # session["PRIVATE_APPS"]=read_private_apps(current_user.email,app)
        return redirect(next_page)
    return render_template('login.html', title='Sign In', form=form)
Пример #2
0
def index():
    if current_user.is_authenticated:
        current_user.user_apps = FREEAPPS + read_private_apps(
            current_user.email, app)
        db.session.add(current_user)
        db.session.commit()
        apps = current_user.user_apps
        return render_template('index.html',
                               userlogged="yes",
                               apps=apps,
                               ashtag=app.config['COMMIT'][:7],
                               instance=app.config['INSTANCE'])
    else:
        return render_template(
            'index.html',
            userlogged="no",
            apps=FREEAPPS,
            ashtag=app.config['COMMIT'][:7],
            instance=app.config['INSTANCE']
        )  # https://flaski.mpg.de/%7B%7B%20url_for('scatterplot')%20%7D%7D