Example #1
0
File: index.py Project: 1025ryu/sns
def login():
	if request.method=="POST":
		form=Userform()
		if form.validate_on_submit():
			
			if user_manager.login_check(form.email.data, form.password.data):
				user=user_manager.get_user_list(form.email.data)
				session['email']=form.email.data
				session['username']=user.username
				session['user_id']=user.id
				session['logged_in'] = True
				
				return render_template('layout.html')
			else:
				login_error="wrong email or password"
				return render_template('login.html',form=form,login_error=login_error)
		# email=request.form['email']
		# password=request.form['password']
		# if user_manager.login_check(email,password):
		# 	session['email']=request.form['email']
		# 	username=user_manager.get_user_list(email).username
		# 	session['user_id']=user_manager.get_user_list(email).id
		# 	session['username']=username
		# 	session['logged_in'] = True
		# 	return render_template('layout.html')
		else:
			login_error="wrong email or password"
			return render_template('login.html',form=form,login_error=login_error)
	else:
		form=Userform()
		return render_template('login.html',form=form)
Example #2
0
def login_submit():
    email = request.form['input-email']
    password = request.form['input-password']

    if not user_manager.login_check(email, password):
        flash(u'로그인에 실패하였습니다. 이메일과 비밀번호를 확인해주세요')
        return redirect(url_for('login'))
    user = user_manager.get_user_by_email(email).one()
    if not user.email_verified:
        flash(u'메일 인증을 완료해주세요')
        return redirect(url_for('login'))
    session['user_id'] = user.id
    return redirect(url_for('index'))
Example #3
0
def login() :
	if request.method == 'POST':
		email = request.form['email']
		pw = request.form['password']
		result = user_manager.login_check(email,pw)
		if result:
			message = "login success!"
			session['logged_in'] = True
			login_user_data = User.query.filter(User.email == request.form['email']).first()
			session['user_id'] = login_user_data.id
			session['email'] = request.form['email']
			return render_template('contents.html', message = message)
		else:
			error = "login fail"
			return render_template('login.html', error = error)
	else:
		return render_template('login.html')
Example #4
0
def login():
    if request.method == 'POST':
        email = request.form['email']
        pw = request.form['password']
        result = user_manager.login_check(email, pw)
        if result:
            message = "login success!"
            session['logged_in'] = True
            login_user_data = User.query.filter(
                User.email == request.form['email']).first()
            session['user_id'] = login_user_data.id
            session['email'] = request.form['email']
            return render_template('contents.html', message=message)
        else:
            error = "login fail"
            return render_template('login.html', error=error)
    else:
        return render_template('login.html')
Example #5
0
def login():
    error= None
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']
        if user_manager.login_check(email, password) == True:
            session['logged_in'] = True
            session['email'] = email
            users = user_manager.get_user(email)
            session['user_id'] = users[0].id  
            flash('You were logged_in')
            return redirect(url_for('posts'))
        else :
            error = "There is no information."
    else :
        pass
        # don't need
    return render_template('login.html', error = error)
Example #6
0
def login() :
	form = UserForm()
	if request.method == 'POST':

		# Validator 안에서 옳은지 안 옳은지 확인해주는 if 문
		if form.validate_on_submit():
			login_success = user_manager.login_check(form.email.data, form.password.data)

			if login_success :
				user = user_manager.get_user_by_email(form.email.data)
				session['user_id'] = user.id
				session['user_name'] = user.username
				return redirect(url_for('newsfeed'))
			else:
				login_error = "wrong email or password"
				return render_template('login.html', form=form, login_error=login_error)

		else :
			return render_template('login.html', form=form)

	else:
		return render_template('login.html', form=form)