示例#1
0
def index():
    """
    View da Tela de Lgin do sistema
    """

    form = LoginForm()

    if form.validate_on_submit():
        # Busca o Usuario pelo Username Informado
        username = form.username.data.lower()
        user = User.query.filter_by(userName=username).first()

        # Verifica se o Usuário Existe e se a Senha está correta
        if user and user.verifyPassword(form.password.data):
            # Faz o Login do usuário
            login_user(user)

            # Redireciona o Usuario para a tela Principal ou a Tela desejada
            return redirect(request.args.get('next') or url_for('dashboard.index'))
        
        # when login details are incorrect
        else:
            message = {'type': 'warning', 'content': 'Usuário ou senha inválido.'}
            flash(message)
    
    content = {
        'title': 'Tela de Login',
        'form': form
    }
    return render_template('login.html', **content)
示例#2
0
def login():
    #如果已经LOGIN,重定向到首页
    if current_user.is_authenticated:
        return redirect('/')
    form = LoginForm()

    if form.validate_on_submit():
        # flash('username="******", password='******'/')

        else:
            flash('username or password is wrong')
            return redirect('auth/login')

    else:
        template_name = 'login.html'
        return render_template(template_name, title='Sign In', form=form)
示例#3
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        flash('username = '******', password = '******'/')
    else:
        return render_template('login.html', title='Sign In', form=form)
示例#4
0
def login():
    if current_user.is_authenticated:
        currID = current_user.get_id()
        adminStatus = User.query.with_entities(
            User.admin_status).filter_by(id=currID).first().admin_status
        # Checks if user is admin OR is editing their own profile page
        if currID == str(id) or adminStatus == True:
            return redirect('/adminPage')
        else:
            return redirect('/alec-check-in')
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(smu_id=form.smu_id.data).first()
        if user is None or not user.check_password(form.password.data):
            flash(u'Invalid password provided', 'danger')
            return redirect('/login')
        login_user(user, remember=form.remember_me.data)
        currID = current_user.get_id()
        adminStatus = User.query.with_entities(
            User.admin_status).filter_by(id=currID).first().admin_status
        # Checks if user is admin OR is editing their own profile page
        if currID == str(id) or adminStatus == True:
            return redirect('/adminPage')
        else:
            return redirect('/alec-check-in')
    return render_template('login.html', title='Sign In', form=form)
示例#5
0
def dologin():
    form = LoginForm()

    if form.validate_on_submit():
        flash('username="******",password='******'/dologin')
    else:
        template_naeme = 'login.html'
        return render_template(template_naeme,title='Sign In',form=form)
示例#6
0
def login():
    if current_user.is_authenticated:
        return redirect('/adminPage')
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(smu_id=form.smu_id.data).first()
        if user is None or not user.check_password(form.password.data):
            flash(u'Invalid password provided', 'danger')
            return redirect('/login')
        login_user(user, remember=form.remember_me.data)
        return redirect('/adminPage')
    return render_template('login.html', title='Sign In', form=form)
示例#7
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user is None or not user.check_password(form.password.data):
            flash('Invalid username or password')
            return redirect(url_for('login'))
        login_user(user, remember=form.remember_me.data)
        next_page = request.args.get('next')
        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('index')
        return redirect(next_page)
    return render_template('login.html', title='Sign In', form=form)
示例#8
0
def login():
    """
    Flask-Login. The APIKEY authentication is actually performed in the api view file.
    We should migrate it here.
    """
    if g.user.is_authenticated:
        return redirect(url_for('index'))

    login_form = LoginForm()
    if login_form.validate_on_submit():
        username = login_form.username.data
        user = api.usercontrol.get_by_name(username)
        if user is None:
            return redirect(url_for('login'))
        if api.usercontrol.check_user_pass(user, login_form.password.data):
            login_user(user, remember=True)
            flash("Logged in!", "success")
            return redirect(url_for("index"))
    return render_template('login.html', title='Sign In', form=login_form)
示例#9
0
def login():
    if current_user.is_authenticated:
        return redirect('/')

    form = LoginForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        user_ctrl = UserCtrl()
        user = user_ctrl.query(Name=username, Password=password)

        if user:
            login_user(user)
            return redirect('/')
        else:
            flash('username or password is wrong')
            return redirect('/auth/login')
    else:
        return render_template('login.html', title='Sign In', form=form)
示例#10
0
def login():
    if current_user.is_authenticated:
        return redirect('/')

    form = LoginForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        user_controller = UserController()
        user = user_controller.query(username=username, password=password)
        print(user)

        if user:
            login_user(user)
            return redirect('/')
        else:
            flash('username or password is worry')
            return redirect('/auth/login')
    else:
        template_naeme = 'login.html'
        return render_template(template_naeme, title='Sign In', form=form)