Exemplo n.º 1
0
def register():
    if request.method == "POST":
        credentials = request.get_json()
        name = credentials['username']
        password = credentials['password']
        password = data_handler.hash_password(password)
        data_handler.insert_user(name, password)
        return jsonify({'success': True})
    return render_template("index.html")
Exemplo n.º 2
0
def add_user():
    if request.method == 'POST':
        password = request.form.get('hash')
        hashed = data_handler.hash_password(password)
        user_info = {'username': request.form.get('username'),
                     'hash': hashed,
                     'email': request.form.get('email'),
                     'creation_date': data_handler.date_time(),
                     'status': request.form.get('status'),
                     }
        data_handler.add_user_details_to_database(user_info)
        return redirect('/')

    return render_template('registration.html')
Exemplo n.º 3
0
def regist():
    if request.method == 'POST':
        current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        username = request.form['username']
        password = request.form['psw']
        password2 = request.form['psw-repeat']
        hashed_psw = data_handler.hash_password(password)
        if password == password2:
            data_handler.SQL_password_username(hashed_psw, username,
                                               current_time)
            return redirect(url_for('route_list'))
        else:
            return render_template('registration-error.html')

    return render_template('registration.html')
Exemplo n.º 4
0
def registration():
    title_text = 'Register new account'

    if request.method == 'POST':
        email = request.form['email']
        if any(user['email'] for user in data_handler.get_emails()):
            error_message = 'Someone already registered with this email: '
            return render_template('registration.html',
                                   title_text=title_text,
                                   email=email,
                                   error_message=error_message)
        password = request.form['password']
        hashed_password = data_handler.hash_password(password)
        registration_date = data_handler.current_time()
        data_handler.add_user(email, hashed_password, registration_date)
        return redirect(url_for('main_page'))
    return render_template('registration.html', title_text=title_text)
Exemplo n.º 5
0
def registration():
    if request.method == 'POST':
        user_name = request.form.get('user_name')
        not_hashed_pw = request.form.get('pw')
        name_status = data_handler.check_if_user_name_exists(user_name)
        if name_status:
            message = 'Name already taken'
            return render_template('registration.html', message=message)
        if user_name == '' or not_hashed_pw == '':
            return render_template('registration.html')
        hashed_password = data_handler.hash_password(not_hashed_pw)
        user_name_and_pw = [user_name, hashed_password]
        data_handler.register_user(user_name_and_pw)
        message = 'Registration successful'
        return render_template('registration.html', message=message)

    else:
        return render_template('registration.html')
Exemplo n.º 6
0
def register(username, password):
    hashed_password = data_handler.hash_password(password)
    persistence.add_user(username, hashed_password)
    return render_template('index.html')