예제 #1
0
def dashboard(page=None):
    company = None
    if current_user.id == 'admin':
        if request.args.get('id'):
            session['company_id'] = request.args.get('id')
        if not session.get('company_id'):
            return redirect('/admin')
        company = get_company(session['company_id'])
    if not page or page == 'accueil':
        return render_template('companies/dashboard/sections/dashboard.html', company=company)
    return render_template('companies/dashboard/sections/{}.html'.format(page), company=company)
예제 #2
0
def update_banner():
    if not current_user.data.get('equipement'):
        company_id = request.form.get('pk')
        banner = request.form.get('value')

        company = get_company(company_id)
        company['banner'] = banner
        set_company(company['id'], company)
        return "success"
    else:
        abort(500)
예제 #3
0
def signin():
    if request.method == 'POST':
        remember_me = 'remember_me' in request.form
        company_id = request.form.get('id')
        password = request.form.get('password')
        company = get_company(company_id)
        # checking stuff out
        if not company_id or not password:
            return render_template('companies/signin.html', error="blank_fields")
        if not company:
            return render_template('companies/signin.html', error="no_company_found")
        if not validate_login(company['password'], password, 'companies'):
            return render_template('companies/signin.html', error="wrong_password")
        # all is good
        company = Company(id=company_id, password=password)
        print(f'connected_as: {company_id}')
        login_user(company, remember=remember_me)
        return redirect(url_for('companies.dashboard'))
    else:
        return render_template('companies/signin.html')
예제 #4
0
파일: login.py 프로젝트: W3SS/forumorg
def load_user(user_id):
    if '@' in user_id:
        return storage.get_user(user_id)
    else:
        return Company(id=user_id, data=storage.get_company(user_id))