Пример #1
0
def register():
    if request.method == 'POST':
        email = request.form['email']
        plain_text_password = request.form['password']
        hashed_password = hash_password(plain_text_password)
        data_manager.add_user(email, hashed_password)
        return redirect(url_for("index"))

    return render_template("registration_form.html")
Пример #2
0
def register():
    if request.method == 'POST':
        username = request.form['username']
        password = data_manager.hash_password(request.form['password'])
        email = request.form['email']
        data_manager.add_user(username, password, email)
        return redirect('/login')

    return render_template('register.html')
Пример #3
0
def registration():
    if request.method == 'GET':
        return render_template('registration.html')
    elif request.method == 'POST':
        new_user_data = {
            'user_name': request.form['user_name'],
            'password': auth.hash_password(request.form['password'])}
        data_manager.add_user(new_user_data)
        return redirect(url_for('list'))
Пример #4
0
def register_check():
    username = request.form['username']
    password = generate_password_hash(request.form['password'], 'sha256')
    users = data_manager.get_users()
    usernames = [u[1] for u in users]
    if username in usernames:
        return redirect('/register?mode=incorrect')
    else:
        data_manager.add_user(username, password)
        return redirect('/')
Пример #5
0
def register():
    new_account = request.form

    if (not data_manager.is_user_in_database(new_account['username'])):
        data_manager.add_user(new_account['username'], new_account['password'])
        session['username'] = new_account['username']
        return redirect(url_for('boards'))
    else:
        msg = 'There is user with "' + new_account['username'] + '" username! Try again'
        return render_template('login.html', msg=msg)
Пример #6
0
def register_user():
    if request.method == 'POST':
        username = request.form['username']
        password = hash.hash_password(request.form['password'])
        registry_date = date.today()
        data_manager.add_user(username, password, registry_date)

        return redirect(url_for('list_5_questions'))

    return render_template('register.html')
Пример #7
0
def registration():
    error = None
    if request.method == 'POST':
        if not data_manager.users(request.form['user_name'])[0]['case'] == 0:
            error = 'E-mail address already in use!'
            return render_template("registration.html", error=error)
        data_manager.add_user(
            request.form['user_name'],
            data_manager.hash_password(request.form['password']))
        return redirect(url_for('index'))
    return render_template("registration.html", error=error)
Пример #8
0
def register_user():
    if request.method == "POST":
        username = request.form['register-username']
        if util.check_if_username_exists(username):
            return render_template('index.html', username_taken=True)
        password = request.form['register-password']
        hashed_password = util.hash_password(password)
        data_manager.add_user(username, hashed_password)
        return redirect(url_for('show_planets'))
    else:
        return redirect(url_for('show_planets'))
Пример #9
0
def register():
    if request.method == "GET":
        return render_template('register_login.html', type="register")
    elif request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]
        if data_manager.add_user(username, password) == "user_already_exists":
            message = "User Already Exists"
            return render_template('register_login.html', type="register", message=message)
        data_manager.add_user(username, password)
        session["username"] = username
        return redirect('/')
Пример #10
0
def register_user():
    if request.method == 'POST':
        user_name = request.form.get('user_name')
        if validation.check_if_user_name_exists(user_name):
            message = 'Name already taken'
            return render_template('registration.html', message=message)
        else:
            password = request.form.get('pw')
            hashed_password = validation.hash_password(password)
            all_input = [user_name, hashed_password]
            data_manager.add_user(all_input)
            message = 'Registration successful'
            return render_template('registration.html', message=message)
    return render_template('registration.html')
Пример #11
0
def new_user():
    login = request.form["uname"]
    password = request.form["psw"]

    login_exist = data_manager.check_user_login(login)

    if login_exist != []:
        login = login.upper()
        flash('Username {login} already exists'.format(login=login))

        return redirect(url_for('register'))
    else:
        flash('Register in succesfully')
        data_manager.add_user(login, password)
        return redirect(url_for('index') )
Пример #12
0
def signup():
    form = RegisterForm()
    if request.method == "POST":
        if form.validate_on_submit():
            hash_pass = ph.hash_password(form.password.data)
            last_name = form.last_name.data
            first_name = form.first_name.data
            email = form.email.data
            user_name = form.username.data
            existing_user = data_manager.existing_user(user_name, email)
            if len(existing_user) == 0:
                data_manager.add_user(user_name, first_name, last_name, email,
                                      hash_pass)
                return render_template('signup.html',
                                       form=form,
                                       status='user_created')
            else:
                return render_template('signup.html',
                                       form=form,
                                       status='user_exist')
    return render_template('signup.html', form=form)
Пример #13
0
def registration():
    registration_data = {}
    if request.method == 'POST':
        if request.form['psw'] != request.form['psw-repeat']:
            flash('Repeated password must be the same, please try again')
            return render_template("registration.html")
        registration_data['user'] = request.form['user']
        registration_data['email'] = request.form['email']
        registration_data['password'] = request.form['psw']
        registration_data['psw-repeat'] = request.form['psw-repeat']
        register_conf = data_manager.check_user(registration_data)
        if not register_conf:
            flash('User with submitted data already exist.')
            return render_template("registration.html")
        data_manager.add_user(registration_data)
        register_conf = 'Registration successful. Please sign in to continue.'
        return redirect(url_for('login', register_conf=register_conf))
    if 'username' in session:
        username_info = f"Signed in as {session['username']}"
        return render_template('registration.html',
                               username_info=username_info)
    else:
        return render_template("registration.html")
Пример #14
0
def register():
    #check if login and password is correct!
    print(request.form)
    login = request.form['login']

    password = request.form['password']
    id_and_name = data_manager.check_user_login_and_password(login, password)

    if id_and_name != []:
        login = login.upper()
        flash('Username {login} already exists'.format(login=login))

        return redirect(url_for('registration'))
    else:
        # place for function adding user to database
        user_id = len(data_manager.get_all_users()) + 1

        data_manager.add_user(user_id, login, password)
        id_and_name = data_manager.check_user_login_and_password(
            login, password)
        session['username'] = id_and_name[0]['name']
        session['id'] = id_and_name[0]['id']

        return redirect(url_for('boards'))
Пример #15
0
def register():
    if request.method == 'GET':
        return render_template('registration.html')
    if request.method == 'POST':
        user_name = request.form['name']
        #surname = request.form['surname']
        # validacja formularza
        login = request.form['login']
        password = bcrypt.hashpw(request.form['password'].encode('utf8'),
                                 bcrypt.gensalt(10))
        print(password)

        user = data_manager.add_user(login, password, user_name)
        session['email'] = login
        login_user(data_manager.User(user))
        return redirect(url_for('index'))