def login(): if 'username' not in session: if request.method == 'POST': name = request.form["username"] password = request.form["password"] if data_manager.get_user_data(name) \ and password_hash.verify_password(password, data_manager.get_user_data(name)[0]['hashed_password']) == True: session['username'] = name return redirect('/') else: return render_template('login.html') return render_template('login.html') else: return redirect('/')
def show_user_data(username): #username = session['username'] user_data = data_manager.get_user_data(username) user_questions = data_manager.get_user_questions(username) user_answers = data_manager.get_user_answers(username) user_comments = data_manager.get_user_comments(username) return render_template('user_data.html', user_data=user_data, user_questions=user_questions, user_answers=user_answers, user_comments=user_comments, username=username)
def login(): if request.method == 'POST': login_data = request.form.to_dict() user_data_from_database = data_manager.get_user_data(login_data) if user_data_from_database: is_correct_password = hash.verify_password( login_data["password"], user_data_from_database["password"]) if is_correct_password: session["username"] = login_data["username"] session["user_id"] = user_data_from_database["id"] return redirect(url_for('index')) return render_template('login.html', failed_login=True) return render_template('login.html')
def route_user_page(name): user = data_manager.get_user_data(name) user_id = user['user_id'] reputation = data_manager.get_user_reputation(user_id) if reputation is not None: if reputation['answer_votes'] is None: reputation['answer_votes'] = 0 if reputation['question_votes'] is None: reputation['question_votes'] = 0 questions = data_manager.get_questions_by_user_id(user_id) answers = data_manager.get_answers_by_user_id(user_id) comments = data_manager.get_comments_by_user_id(user_id) return render_template('user-page.html', user=user, reputation=reputation, questions=questions, answers=answers, comments=comments)
def login(): if request.method == 'GET': return render_template('login.html') if request.method == 'POST': username = request.form['uname'] password = request.form['pwd'] user_data = data_manager.get_user_data(username) if not user_data: success = False return render_template('login.html', success=success) else: verified_pw = data_manager.verify_password(password, user_data['password']) if verified_pw: session['username'] = username session['user_id'] = user_data['id'] return redirect('/') else: success = False return render_template('login.html', success=success)
def login(): error = None next = request.args.get('next') if request.method == "POST": #email = request.args.get('email') #password = request.args.get('password') email = request.form['email'] # autentykacja - hashowanie i tokeny user = data_manager.get_user_data(email) if user: user = data_manager.User(user) print(user.password_hash) # sprawdzenie hashu if user.password(request.form['password']): login_user(user) session['email'] = email return redirect(url_for('index')) error = "Login failed" return render_template('login.html', error=error)
def user_list(): user_data = data_manager.get_user_data() return render_template('user_list.html', user_data=user_data)
def user(): fieldname = ["Question title", "Question message", "Answer message", "Comment message"] user = data_manager.get_user_data(session['user_id']) return render_template('user.html', user=user, fieldname=fieldname)
def user_page(email): user_email = email user_data = data_manager.get_user_data(user_email) return render_template('users_list.html', users_data=user_data, users_data_headers=USERS_DATA_HEADERS)
def route_users(): users = data_manager.get_user_data() return render_template('users.html', users=users)
def list_users(): users = data_manager.get_user_data() return render_template("user.html", users=users)