Exemplo n.º 1
0
def sign_up():
   
    if current_user.is_authenticated:
        return redirect(url_for('user_bag', user_id=current_user.id))

    form = Sign_up_form()
    if request.method == "POST" and form.validate_on_submit():
        email = form.email.data
        name = request.form['name']
        password = form.password.data
        user = User.query.filter_by(email=email).first()

        if user:
            flash("This email is already exists")
            return redirect(url_for('sign_up'))

        new_user = User(email=email, name=name, password=generate_password_hash(password))
        insert_user(new_user)
        msg = Message("Hi there", recipients=[new_user.email])
        msg.html = """<h1 style='color:green'>Hello in write&Note</h1>
                        <h2>Write&Note website will help you record your notes
                            in a wonderful way ..let's start now! Happy trip.</h2><br>
                            <img src='{{ url_for('static', filename='write1.jpg') }}'>""" 
        # with app.open_resource("write1.jpg") as img:
        #     msg.attach('write1.jpg', 'image/jpeg', img.read())
        mail.send(msg)

        login_user(User.query.filter_by(email=email).first())
        return redirect(url_for('user_bag', user_id=new_user.id))

    return render_template('signup.html', form=form)
Exemplo n.º 2
0
def home():
    if request.method == 'POST':
        username = request.form['username']
        dbHandler.insert_user(username)
        users = dbHandler.retrieve_users()
        return render_template('index.html', users=users)
    else:
        return render_template('index.html')
Exemplo n.º 3
0
def add_user():
    if not request.json or not 'user' in request.json:
        abort(400)

    user = request.json['user']

    models.insert_user(user, request.json['email'], request.json['pass'], request.json['first'])

    return jsonify({'users': models.select_by_username(user)}), 201
Exemplo n.º 4
0
def insert_user():
    user = serializers.users_from_web(**request.json)
    if valida_user(**user):
        id_usuario = models.insert_user(**user)
        inserted_user = models.get_user(id_usuario)
        return jsonify(serializers.users_from_db(inserted_user))
    else:
        return jsonify({"erro": "Usuário inválido"})
Exemplo n.º 5
0
def signup():
    
    error = ""

    if request.method == 'POST':
        username = request.form['username']
        email = request.form['email']
        password = request.form['password']
        password_conf = request.form['password_conf']
        # TODO: Sanitise and validate input here

        if not dbHandler.is_unique_email(email):
            error += "This email address is already associated with an account."

        if password != password_conf:
            error += "Please ensure passwords match"
        if not error:  
            dbHandler.insert_user(username, email, hasher.hash(password), node_list.get_newest_node())
            return redirect(url_for('login'))

    # Display form and error message (if any) here
    return render_template("signup.html", err_msg = error)
Exemplo n.º 6
0
def create_user():
    user = request.get_json()

    if user is None:
        abort(404)

    logger.debug(user)

    result = models.insert_user(user['username'], user['name'], user['email'])

    if not result:
        abort(409)

    return make_response(jsonify('OK'), 201)
Exemplo n.º 7
0
def check_account(username):
    if not models.fetch_user(username):
        private_key, address, passphrase = create_wallet()
        passphrase = mnemonic.from_private_key(private_key)
        models.insert_user(username, address, private_key, passphrase)
    return True
Exemplo n.º 8
0
import os
import models

BOT_NAME = os.getenv('BOT_NAME', 'Token Not found')
BOT_ADDRESS = os.getenv('BOT_ADDRESS', 'Token Not found')
BOT_PRIVATE_KEY = os.getenv('BOT_PRIVATE_KEY', 'Token Not found')
BOT_MNEMONIC = os.getenv('BOT_MNEMONIC', 'Token Not found')

conn = models.sql_connection()
models.create_database(conn)
models.insert_user(BOT_NAME,BOT_ADDRESS,BOT_PRIVATE_KEY,BOT_MNEMONIC)
Exemplo n.º 9
0
Arquivo: views.py Projeto: harr/rewind
def signup_confirm():
    user = insert_user(request.form['username'], request.form['password'])
    login_user(user)
    return redirect('/')