Example #1
0
def login():
    if request.method == 'GET':
        return render_template('sign_in.html')
    else:
        username = request.form['username']
        password = request.form['password']
        role = request.form['role']
        mysql = Mysql_service()

        name, real_pass, role, email, address, account, credit = mysql.getUserInfoByUsername(
            username)
        if password == real_pass:
            if role == 'Product':
                session['username'] = name
                return render_template('signin_sailer_index.html',
                                       username=name,
                                       email=email,
                                       address=address)
            if role == 'Transport':
                session['username'] = name
                return render_template('signin_trans_index.html',
                                       username=name,
                                       email=email,
                                       address=address)
            if role == 'Sale':
                session['username'] = name
                return render_template('signin_custs_index.html',
                                       username=name,
                                       email=email,
                                       address=address)
        else:
            print("======登录失败======")
            # 这里还没有考虑怎么样的返回界面
            return render_template('sign_in.html', res="fail")
Example #2
0
def signin_sailer_system():
    username = session['username']
    mysql = Mysql_service()
    [name, password, role, email, address, account,
     credit] = mysql.getUserInfoByUsername(username)
    return render_template('signin_sailer_system.html',
                           username=username,
                           credit=credit)