Beispiel #1
0
def register():
    """
    The app route for the register page, allowing users to register to the database.

    :return: :rtype: Returns the redirect for the homepage if the user is succesfully registered
    else renders the register home page if the user fails to login properly.
    """
    error = None
    if request.method == 'POST':
        if request.form['username'] == "":
            error = 'Must input username'
        elif request.form['password'] == "":
            error = 'Must input password'
        elif request.form['firstname'] == "":
            error = 'Must input firstname'
        elif request.form['lastname'] == "":
            error = 'Must input lastname'
        else:
            username=request.form['username']
            password=request.form['password']
            firstname=request.form['firstname']
            lastname=request.form['lastname']
            db.register_user(username,password,firstname,lastname)
            session['logged_in'] = True
            flash('You were registered')
            return redirect(url_for('index'))
    return render_template('register.html', error=error)
Beispiel #2
0
def register():
    form = forms.RegisterForm()
    if form.validate_on_submit():
        db.register_user(form.username.data, form.password.data,
                         form.email.data, form.dob.data,
                         'Tell us a bit about yourself')
        flash("Registration Successful", "success")
        return redirect(url_for('index'))
    return render_template('register.html', form=form)
Beispiel #3
0
def handle_start(message):
    _logger.info("/start")
    bot.reply_to(message, "Welcome!")
    users = db.get_user(message.from_user.id)
    if users.count() == 0:
        db.register_user(
            message.from_user.id,
            message.from_user.first_name,
            message.from_user.last_name,
            message.from_user.username)
Beispiel #4
0
def index():
    username = request.forms.get('username')
    password = request.forms.get('password')
    confirm = request.forms.get('confirm')
    if username and password and confirm:
        pass
    else:
        return template('/var/bottle/template/register', error="don't empty")
    if password != confirm:
        return template('/var/bottle/template/register',
                        error="Different password")
    if len(password) < 6:
        return template('/var/bottle/template/register',
                        error='password too small')
    if len(password) > 30:
        return template('/var/bottle/template/register',
                        error='password too long')
    if len(username) > 20:
        return template('/var/bottle/template/register',
                        error='username too long')
    register_status = db.register_user(username, password)
    if register_status == 2:
        return template('/var/bottle/template/register',
                        error='username already exist')
    if register_status == 1:
        return bottle.redirect('/path?path=/login')
    if register_status == 0:
        return template('/var/bottle/template/register',
                        error='Registration failed')
Beispiel #5
0
def register():
    if request.method == 'POST':
        email = request.form['email']
        record_confirmed = request.form.get("record_confirmed") != None
        record_fatalities = request.form.get("record_fatalities") != None
        top_5_most_confirmed = request.form.get("top_5_most_confirmed") != None
        top_5_most_fatalities = request.form.get("top_5_most_fatalities") != None
        top_5_least_confirmed = request.form.get("top_5_least_confirmed") != None
        top_5_least_fatalities = request.form.get("top_5_least_fatalities") != None
        total_fatalities_highest = request.form.get("total_fatalities_highest") != None
        total_confirmed_highest = request.form.get("total_confirmed_highest") != None
        error = db.register_user(email, record_confirmed, record_fatalities,
        top_5_most_confirmed, top_5_most_fatalities,
        top_5_least_confirmed, top_5_least_fatalities,
        total_fatalities_highest, total_confirmed_highest, None)
        if error is None:
            return redirect('/landing')
        else:
            if error.args[0] == 1062:
                dup_property = 'email'
                error_msg = ('There is already an account'
                        ' with that {}.'.format(dup_property))
            return render_template(
                'register.html',
                error=error_msg,
            )
    return render_template('register.html')
Beispiel #6
0
def sample_data(conf):
    bucket = get_bucket(conf)
    bucket.on_connect()
    collection = bucket.default_collection()
    return [
        register_user(
            collection,
            CreateUser.Schema().loads({
                "name": "Rob",
                "email": "*****@*****.**"
            })),
        register_user(
            collection,
            CreateUser.Schema().loads({
                "name": "Gregor",
                "email": "*****@*****.**"
            }))
    ]
def register_new_user():
    try:
        print("register new user")
        uuid = request.json['uuid']
        push_notification_id = request.json['pushnotificationid']
        date = request.json['date']
        type = request.json['type']
        user_id = db.register_user(type, date, uuid, push_notification_id)
        return json.dumps({"userid": user_id})
    except:
        client.captureException()
Beispiel #8
0
def register():
    if request.method == 'GET':
        return render_template('register.html');
    else:
        if request.form['password'] != request.form['pw_verify']:
            return render_template('register.html', error='Passwords do not match')
        if db.register_user(request.form['username'],request.form['password']):
            session['username'] = request.form['username']            
            return redirect(url_for('read'))
        else:
            return render_template('register.html', error='Username already exists')
Beispiel #9
0
def register():
    """
    The app route for the register page, allowing users to register to the database.

    :return: :rtype: Returns the redirect for the homepage if the user is succesfully registered
    else renders the register home page if the user fails to login properly.
    """
    if request.method == 'POST':
        if request.form['username'] == "":
            error = 'Must input username'
        elif request.form['password'] != request.form['confirmed_password']:
            error = 'Inputted password and confirmed password, must match'
        elif request.form['firstname'] == "":
            error = 'Must input firstname'
        elif request.form['lastname'] == "":
            error = 'Must input lastname'
        elif request.form['email'] == "":
            error = 'Must input email'
        elif request.form['org_no'] == "":
            error = 'Must input organization number or SSN'
        elif request.form['org_name'] == "":
            error = 'Must input company name'
        elif request.form['address_field1'] == "":
            error = 'Must input Address'
        elif request.form['zipcode'] == "":
            error = 'Must input zip code'
        elif request.form['city'] == "":
            error = 'Must input city'
        else:
            username = request.form['username']
            password = request.form['password']
            firstname = request.form['firstname']
            lastname = request.form['lastname']
            email = request.form['email']
            telephone = request.form['telephone']
            org_no = request.form['org_no']
            org_name = request.form['org_name']
            address_field1 = request.form['address_field1']
            address_field2 = request.form['address_field2']
            zipcode = request.form['zipcode']
            city = request.form['city']
            print "dit"

            if not db.register_user(username, password, firstname, lastname, email, telephone, org_no, org_name, address_field1, address_field2, zipcode, city):
                message = 'The username already exists'
                return render_template('register.html', message=message)
            else:
                session['logged_in'] = True
                session['authority'] = db.get_authority(username)
                session['username'] = username
            return redirect(url_for('index'))
        return render_template('register.html', error=error)
    return render_template('register.html')
Beispiel #10
0
def register():
    register_message = ''
    if request.method == 'GET':
        return render_template('register.html')
    else:
        username = request.form.get('username')
        password = request.form.get('password')
        if username and password:
            register_message = register_user(username, password)
            if register_message == 'success':
                user = get_user(username)
                login_user(user)
                return redirect(url_for('home'))
        else:
            register_message = 'All fields are required'
        return render_template('register.html',
                               register_message=register_message)
Beispiel #11
0
def registerUser():
    status = ""
    data = request.get_json()
    if data['password'] != data['cpassword']:
        status = "password and confirm password does not match"
    else:
        status = db.register_user(data['email'], data['password'])
    time.sleep(
        1
    )  ## to see the spinner loading add this or remove this for fast response
    try:
        base_dir = os.path.abspath(os.path.dirname(__file__))
        os.mkdir(os.path.join(base_dir, "static", "files", data['email']))
    except Exception as e:
        print(str(e))
    response = {'status': status}
    return jsonify(response)
Beispiel #12
0
def register():
    if request.method == 'GET':
        return render_template('register.html')

    email = request.form['email']
    password = request.form['password']
    fname = request.form['fname']
    lname = request.form['lname']
    confirm = request.form['confirm']

    if password != confirm:
        error = 'Password does not match'
        return render_template('register.html', error=error)

    success, message = register_user(email, password, fname, lname)
    if not success:
        return render_template('register.html', error=message)

    session['email'] = email
    session['fname'] = fname
    session['lname'] = lname
    return redirect('/')
Beispiel #13
0
 async def register(self, ctx):
     user_id = ctx.message.author.id
     print(f"registering {user_id}")
     db.register_user(user_id)