Esempio n. 1
0
def update_user(id):
    update_user_form = CreateUserForm(request.form)
    if request.method == 'POST' and update_user_form.validate():
        users_dict = {}
        db = shelve.open('account.db', 'c')
        users_dict = db['Users']

        user = users_dict.get(id)
        user.set_username(update_user_form.username.data)
        user.set_email(update_user_form.email.data)
        user.set_gender(update_user_form.gender.data)
        user.set_password(update_user_form.password.data)

        db['Users'] = users_dict
        db.close()

        session['user_updated'] = user.get_username()

        return redirect(url_for('retrieve_users'))
    else:
        users_dict = {}
        db = shelve.open('account.db', 'r')
        users_dict = db['Users']
        db.close()

        user = users_dict.get(id)
        update_user_form.username.data = user.get_username()
        update_user_form.email.data = user.get_email()
        update_user_form.gender.data = user.get_gender()
        update_user_form.password.data = user.get_password()
        update_user_form.confirm_password.data = user.get_confirm_password()

        return render_template('updateAccount.html', form=update_user_form)
Esempio n. 2
0
def updateUser(id):
    updateUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and updateUserForm.validate():
        userDict = {}
        db = shelve.open('storage.db', 'w')
        userDict = db['Users']
        user = userDict.get(id)
        user.set_username(updateUserForm.username.data)
        user.set_password(updateUserForm.password.data)
        user.set_membership(updateUserForm.membership.data)
        user.set_gender(updateUserForm.gender.data)
        db['Users'] = userDict
        db.close()
        return redirect(url_for('retrieveUsers'))
    else:
        userDict = {}
        db = shelve.open('storage.db', 'r')
        userDict = db['Users']
        db.close()

        user = userDict.get(
            id)  #retrieve user data of specific id into user variable
        updateUserForm.username.data = user.get_username()
        updateUserForm.password.data = user.get_password()
        updateUserForm.membership.data = user.get_membership()
        updateUserForm.gender.data = user.get_gender()
        return render_template('updateUser.html', form=updateUserForm)
Esempio n. 3
0
def create_user():
    create_user_form = CreateUserForm(request.form)
    if request.method == 'POST' and create_user_form.validate():
        users_dict = {}
        db = shelve.open('account.db', 'c')

        try:
            users_dict = db['Users']
        except:
            print("Error in retrieving Users from account.db.")

        user = User(create_user_form.username.data,
                    create_user_form.email.data, create_user_form.gender.data,
                    create_user_form.password.data,
                    create_user_form.confirm_password.data)
        user.set_date_time(user.get_date_time())
        users_dict[user.get_user_id()] = user
        db['Users'] = users_dict

        db.close()

        session['user_created'] = user.get_username()

        return redirect(url_for('home'))
    return render_template('CreateAccount.html', form=create_user_form)
Esempio n. 4
0
def createUser():
    createUserForm = CreateUserForm(request.form)
    username = createUserForm.username.data
    password = createUserForm.password.data
    domain = username
    if request.method == 'POST' and createUserForm.validate():
        usersDict = {}
        db = shelve.open('storage.db', 'c')
        try:
            usersDict = db['Users']
            User.User.countID = db['usercount']
        except:
            print("Error in retrieving Users from storage.db.")
        if checkUserExists(createUserForm.username.data):
            return render_template('createUser.html', form=createUserForm,error='User name exists')
        else:
            user = User.User(createUserForm.firstName.data, createUserForm.lastName.data, createUserForm.username.data,createUserForm.password.data,createUserForm.gender.data,createUserForm.country.data,createUserForm.address.data,createUserForm.number.data)
            usersDict[user.get_userID()] = user
            db['Users'] = usersDict
            # Test codes
            usersDict = db['Users']
            user = usersDict[user.get_userID()]
            print(user.get_firstName(), user.get_lastName(), "was stored in shelve successfully with userID =",
                  user.get_username())
            db.close()
        return redirect(url_for('home'))
    return render_template('createUser.html', form=createUserForm,error='')
Esempio n. 5
0
def createUser():
    createUserForm = CreateUserForm(request.form)
    if request.method == "POST" and createUserForm.validate():
        usersDict = {}
        db = shelve.open("storage.db", "c")

        try:
            usersDict = db["Users"]
        except:
            print("Error in retrieving Users from storage.db")
        user = User.User(createUserForm.firstName.data,
                         createUserForm.lastName.data,
                         createUserForm.membership.data,
                         createUserForm.gender.data,
                         createUserForm.remarks.data)
        db["Users"] = usersDict
        usersDict[user.get_userID()] = user
        print(user.get_firstName(), user.get_lastName(),
              "was stored in shelve successfully with userID =",
              user.get_userID())

        db.close()

        return redirect(url_for("home"))
    else:
        print("Hi")
    return render_template("createUser.html", form=createUserForm)
def to_register():
    create_user_form = CreateUserForm(request.form)
    if request.method == 'POST' and create_user_form.validate():
        users_dict = {}
        db = shelve.open('GoFit.db', 'c')

        try:
            users_dict = db['Users']
        except:
            print("Error in retrieving Users from GoFit.db.")

        user = User.User(create_user_form.username.data,
                         create_user_form.first_name.data,
                         create_user_form.last_name.data,
                         create_user_form.password.data,
                         create_user_form.email.data,
                         create_user_form.contact_number.data)
        users_dict[user.get_user_id()] = user
        db['Users'] = users_dict
        db.close()

        session['username'] = user.get_username()
        session['type'] = "user"

        return redirect(url_for('to_login'))
    return render_template('login/signup.html', form=create_user_form)
Esempio n. 7
0
def createUser():
    createUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and createUserForm.validate():
        usersDict = {}
        db = shelve.open('storage.db', 'c')
        try:
            usersDict = db['Users']
        except:
            print("Error in retrieving Users from storage.db.")
        user = User.User(createUserForm.firstName.data,
                         createUserForm.lastName.data,
                         createUserForm.gender.data,
                         createUserForm.membership.data,
                         createUserForm.remarks.data)
        usersDict[user.get_userID()] = user
        db['Users'] = usersDict
        # Test codes
        usersDict = db['Users']
        user = usersDict[user.get_userID()]
        print(user.get_firstName(), user.get_lastName(),
              "was stored in shelve successfully with userID =",
              user.get_userID())
        db.close()
        return redirect(url_for('home'))
    return render_template('createUser.html', form=createUserForm)
Esempio n. 8
0
def updateUser(id):
    updateUserForm = CreateUserForm(request.form)
    if request.method == "POST" and updateUserForm.validate():
        db = shelve.open("storage.db", "w")
        userDict = db["Users"]

        user = userDict.get(id)
        user.set_firstName(updateUserForm.firstName.data)
        user.set_lastName(updateUserForm.lastName.data)
        user.set_membership(updateUserForm.membership.data)
        user.set_gender(updateUserForm.gender.data)
        user.set_remarks(updateUserForm.remarks.data)

        db["Users"] = userDict
        db.close()

        return redirect(url_for("retrieveUsers"))
    else:
        db = shelve.open("storage.db", "r")
        userDict = db["Users"]
        db.close()

        user = userDict.get(id)
        updateUserForm.firstName.data = user.get_firstName()
        updateUserForm.lastName.data = user.get_lastName()
        updateUserForm.membership.data = user.get_membership()
        updateUserForm.gender.data = user.get_gender()
        updateUserForm.remarks.data = user.get_remarks()

        return render_template("updateUser.html", form=updateUserForm)
Esempio n. 9
0
def update_user(id):
    update_user_form = CreateUserForm(request.form)
    if request.method == 'POST' and update_user_form.validate():
        users_dict = {}
        db = shelve.open('storage.db', 'w')
        users_dict = db['Users']

        user = users_dict.get(id)
        user.set_first_name(update_user_form.first_name.data)
        user.set_last_name(update_user_form.last_name.data)
        user.set_gender(update_user_form.gender.data)
        user.set_membership(update_user_form.membership.data)
        user.set_remarks(update_user_form.remarks.data)

        db['Users'] = users_dict
        db.close()

        session['user_updated'] = user.get_first_name() + ' ' + user.get_last_name()

        return redirect(url_for('retrieve_users'))
    else:
        users_dict = {}
        db = shelve.open('storage.db', 'r')
        users_dict = db['Users']
        db.close()

        user = users_dict.get(id)
        update_user_form.first_name.data = user.get_first_name()
        update_user_form.last_name.data = user.get_last_name()
        update_user_form.gender.data = user.get_gender()
        update_user_form.membership.data = user.get_membership()
        update_user_form.remarks.data = user.get_remarks()

        return render_template('updateUser.html', form=update_user_form)
Esempio n. 10
0
def create_user():
    create_user_form = CreateUserForm(request.form)
    if request.method == 'POST' and create_user_form.validate():
        users_dict = {}
        db = shelve.open('storage.db', 'c')

        try:
            users_dict = db['Users']

        except:
            print("Error in retrieving Users from storage.db.")

        user = User.User(
            create_user_form.first_name.data, create_user_form.last_name.data,
            create_user_form.gender.data, create_user_form.email.data,
            create_user_form.phone.data, create_user_form.address.data,
            create_user_form.password.data)
        users_dict[user.get_user_id()] = user
        db['Users'] = users_dict

        db.close()

        session['user_created'] = user.get_first_name(
        ) + ' ' + user.get_last_name()
        return redirect(url_for('retrieve_users'))
    return render_template('createUser.html', form=create_user_form)
Esempio n. 11
0
def create_user():
    form = CreateUserForm(request.form)
    if request.method == 'POST' and form.validate():
        member = create_member(form.firstName.data, form.lastName.data,
                               form.gender.data, form.membership.data,
                               form.remarks.data)
        # for debugging purpose
        print('created', member.id, member.first_name)
        return redirect(url_for('home'))
    return render_template('createUser.html', form=form)
def signup():
    if current_user.is_authenticated:
        return redirect(url_for('home'))

    form = CreateUserForm()
    if form.validate_on_submit():
        # email
        hashed_email_data = hashlib.sha256(
            form.email.data.encode()).hexdigest()
        exists = False
        user_list = User.query.filter_by(email=hashed_email_data).all()
        if len(user_list) >= 1:
            exists = True

        # check username
        exists2 = False
        user_list = User.query.filter_by(username=form.username.data).all()
        if len(user_list) >= 1:
            exists2 = True
        if not exists and not exists2:
            # bcrypt
            hashed_password = bcrypt.hashpw(form.password.data.encode(),
                                            bcrypt.gensalt(rounds=16))
            hashed_security_Q = bcrypt.hashpw(
                form.security_questions.data.encode(), bcrypt.gensalt())
            hashed_security_ans = bcrypt.hashpw(
                form.security_questions_answer.data.encode(),
                bcrypt.gensalt(rounds=16))
            # bcrypt
            newuser = User(public_id=str(uuid.uuid4()),
                           username=form.username.data,
                           email=hashed_email_data,
                           password=hashed_password,
                           security_questions=hashed_security_Q,
                           security_questions_answer=hashed_security_ans,
                           is_active=True,
                           is_authenticated=False,
                           is_admin=False)
            db.session.add(newuser)
            db.session.commit()
            flash("You have successfully signed up!")
            # return redirect(url_for('login'))

            # 2FA - redirect to the two-factor auth page, passing username in session
            session['username'] = form.username.data
            return redirect(url_for('two_factor_setup'))

        if exists:
            flash("Email exists!")
        if exists2:
            flash("Username is taken!")
        return redirect(url_for('signup'))
    return render_template('sign up.html', title="Sign Up", form=form)
def createUser():
    createUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and createUserForm.validate(
    ):  #only runs if post button clicked
        usersDict = {}
        db = shelve.open(
            'storage.db', 'c'
        )  #assign storage file to variable database, c stands for read and write
        try:
            usersDict = db['Users']  #assign Users storage into usersDict
        except:
            print("Error in retrieving Users from storage.db.")

        for i in usersDict:
            if usersDict[i].get_username() == createUserForm.username.data:
                return render_template('createUser.html',
                                       form=createUserForm,
                                       exist=True)

        if len(usersDict) != 0:
            usersDictKeys = list(usersDict)
            User.User.countID = usersDictKeys[
                -1] + 1  #new countID is the key of last item in usersDict, + 1
        else:
            User.User.countID = 1

        #create list of data into 'user' variable
        user = User.User(
            createUserForm.username.data,
            createUserForm.firstName.data,
            createUserForm.lastName.data,
            createUserForm.password.data,
            createUserForm.gender.data,
        )
        usersDict[
            user.get_userID()] = user  #put 'user' variable into usersDict

        db['Users'] = usersDict  #update new 'Users' in database
        db.close()  #always close your databaseu

        #test codes, left here for fun#############
        #usersDict = db['Users'] #update 'usersDict' with new users, same as line 22

        #user = usersDict[user.get_userID()] #from variable in line 27, get user id, refresh 'user' variable from updated dictionary, idk why honestly
        #print(user.get_username(), "was stored in shelve successfully with userID =", user.get_userID()) #console output to confirm success
        ###########################################

        return redirect(url_for(
            'login'))  #go back to this page on successful post/creation
    return render_template(
        'createUser.html', form=createUserForm
    )  #refresh page, createUserForm variable created in line 16, for form get and post
Esempio n. 14
0
def createProduct():
    createUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and createUserForm.validate():
        usersDict = {}
        db = shelve.open('storage.db', 'c')

        try:
            usersDict = db['Users']
        except:
            print("Error in retrieving Users from storage.db.")
    
        user = User.User(createUserForm.productName.data, createUserForm.category.data,
                         createUserForm.brand.data, createUserForm.quantity.data, createUserForm.price.data,
                         createUserForm.description.data)
        usersDict[user.get_userID()] = user
        db['Users'] = usersDict
        db.close()

        return redirect(url_for('retrieveProducts'))
    return render_template('createProduct.html', form=createUserForm)
Esempio n. 15
0
def create_user():
    create_user_form = CreateUserForm(request.form)
    global nric
    if request.method == 'POST' and create_user_form.validate():
        patient_dict = []

        db = shelve.open('storage.db', 'c')

        try:
            patient_dict = db['Patient']
        except:
            print("Error in retrieving Users from storage.db.")

        patient = janineClass.Patient(create_user_form.purpose.data,
                                      create_user_form.clinic.data,
                                      create_user_form.date_of_arrival.data,
                                      create_user_form.time.data,
                                      create_user_form.message.data)
        patient.set_nric(nric)
        patient_dict.append(patient)
        # global pt_id
        # pt_id=id
        db['Patient'] = patient_dict
        print(patient_dict)
        db.close()
        return redirect(url_for('retrieve_appt'))

    else:
        user_dict = {}
        public_db = shelve.open('public_storage.db', 'r')
        user_dict = public_db['Users']
        public_db.close()
        if nric in user_dict:
            user = user_dict.get(nric)
            create_user_form.name.data = user.get_name()
            create_user_form.nric.data = user.get_nric()
            create_user_form.email.data = user.get_email()
            create_user_form.phone.data = user.get_phone()

    return render_template('createAppointment.html', form=create_user_form)
Esempio n. 16
0
def createUser():
    createUserForm = CreateUserForm(request.form)
    if request.method == "POST" and createUserForm.validate():
        db = shelve.open("storage.db", "c")
        try:
            usersDict = db["Users"]
            User.User.countID = int(list(usersDict.keys())[-1])
        except:
            usersDict = {}
            print("Error in retrieving Users from storage.db")
        #? using class to create user instance
        user_instance = User.User(createUserForm.firstName.data,
                                  createUserForm.lastName.data,
                                  createUserForm.gender.data,
                                  createUserForm.membership.data,
                                  createUserForm.remarks.data)
        usersDict[user_instance.get_userID()] = user_instance
        db["Users"] = usersDict
        db.close()

        return redirect(url_for("retrieveUsers"))
    return render_template("createUser.html", form=createUserForm)
Esempio n. 17
0
def updateUser(id):
    updateUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and updateUserForm.validate():
        userDict = {}
        db = shelve.open("storage.db", "w")
        userDict = db["Users"]
        user = userDict.get(id)
        user.set_firstName(updateUserForm.firstName.data)
        user.set_lastName(updateUserForm.lastName.data)
        user.set_membership(updateUserForm.membership.data)
        user.set_gender(updateUserForm.gender.data)
        user.set_remarks(updateUserForm.remarks.data)
        db["Users"] = userDict
        db.close()
        return redirect(url_for("retrieveUsers"))
    else:
        userDict = {}
        db = shelve.open('storage.db', 'r')
        userDict = db['Users']
        db.close()
        user = userDict.get(id)
        updateUserForm.firstName.data = user.get_firstName()
        updateUserForm.lastName.data = user.get_lastName()
        updateUserForm.membership.data = user.get_membership()
        updateUserForm.gender.data = user.get_gender()
        updateUserForm.remarks.data = user.get_remarks()
        return render_template('updateUser.html', form=updateUserForm)


#@app.route('/deleteUser/<int:id>', methods=['POST'])
#def deleteUser(id):
#    usersDict = {}
#    db = shelve.open('storage.db', 'w')
#    usersDict = db['Users']
#    usersDict.pop(id)
#    db['Users'] = usersDict
#    db.close()
#    return redirect(url_for('retrieveUsers'))
def createUser():
    createUserForm = CreateUserForm(request.form)
    if request.method == 'POST' and createUserForm.validate():
        usersDict = {}
        db = shelve.open('storage.db', 'c')

        try:
            usersDict = db['Users']
        except:
            print("Error in retrieving Users from storage.db.")

        # ERROR
        user = User.User(createUserForm.firstName.data,
                         createUserForm.lastName.data,
                         createUserForm.gender.data,
                         createUserForm.membership.data,
                         createUserForm.remarks.data,
                         createUserForm.product1.data)

        # FIX
        if len(usersDict) != 0:
            lastUserId = usersDict[list(usersDict.keys())[-1]].get_userID()
            user.set_userID(lastUserId + 1)

        usersDict[user.get_userID()] = user
        db['Users'] = usersDict

        # Test codes
        #usersDict = db['Users']
        #user = usersDict[user.get_userID()]
        #print(user.get_firstName(), user.get_lastName(), "was stored in shelve successfully with userID =", user.get_userID())

        db.close()

        return redirect(url_for('retrieveUsers'))
        #return redirect(url_for('home'))
    return render_template('createUser.html', form=createUserForm)
Esempio n. 19
0
def updateUser():
    id = request.args.get('id', default = 1, type = int)
    updateUserForm = CreateUserForm(request.form)

    if request.method == 'POST' and updateUserForm.validate():
        userDict = {}
        db = shelve.open('storage.db', 'w')
        userDict = db['Users']

        user = userDict[id]
        user.set_firstName(updateUserForm.firstName.data)
        user.set_lastName(updateUserForm.lastName.data)
        user.set_username(updateUserForm.username.data)
        user.set_password(updateUserForm.password.data)
        user.set_gender(updateUserForm.gender.data)
        user.set_country(updateUserForm.country.data)
        user.set_address(updateUserForm.address.data)
        user.set_number(updateUserForm.number.data)

        db['Users'] = userDict
        db.close()
        return render_template('updateUser.html',form=updateUserForm, error='Account has been updated')
    else:
        userDict = {}
        db = shelve.open('storage.db', 'r')
        userDict = db['Users']
        db.close()
        user = userDict[id]
        updateUserForm.firstName.data = user.get_firstName()
        updateUserForm.lastName.data = user.get_lastName()
        updateUserForm.username.data = user.get_username()
        updateUserForm.gender.data = user.get_gender()
        updateUserForm.country.data = user.get_country()
        updateUserForm.address.data = user.get_address()
        updateUserForm.number.data = user.get_number()
    return render_template('updateUser.html',form=updateUserForm, error='')
Esempio n. 20
0
def createQn():
    if current_user.is_authenticated:
        createUserForm = CreateUserForm(request.form)
        if request.method == 'POST':
            faq = shelve.open('faq.db', 'c')
            qndict = {}
            user = FaqUser.User(createUserForm.firstName.data,
                                createUserForm.lastName.data,
                                createUserForm.topic.data,
                                createUserForm.question.data)
            if user.get_topic() == 'M':
                try:
                    qndict = faq['M']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['M'] = qndict
                faq.close()

            elif user.get_topic() == 'B':
                try:
                    qndict = faq['B']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['B'] = qndict
                faq.close()

            elif user.get_topic() == 'A':
                try:
                    qndict = faq['A']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['A'] = qndict
                faq.close()

            elif user.get_topic() == 'Pay':
                try:
                    qndict = faq['Pay']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['Pay'] = qndict
                faq.close()

            elif user.get_topic() == 'Pri':
                try:
                    qndict = faq['Pri']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['Pri'] = qndict

                faq.close()

            elif user.get_topic() == 'D':
                try:
                    qndict = faq['D']
                except:
                    print("Error in retrieving Users from storage.db.")

                qndict[user.get_question()] = user
                faq['D'] = qndict

                faq.close()

            return redirect(url_for('faq'))
        else:
            createUserForm.firstName.data = current_user.username

            return render_template('contact.html', form=createUserForm)
    else:
        return render_template('denied.html')
Esempio n. 21
0
def signup():
    if current_user.is_authenticated:
        return redirect(url_for('home'))

    form = CreateUserForm()
    if form.validate_on_submit():

        # hashed_username_data = hashlib.sha256(form.username.data.encode()).hexdigest()

        # --Plaintext---
        # exists = db.session.query(User.id).filter_by(email=form.email.data).scalar()
        # exists2 = db.session.query(User.id).filter_by(username=form.username.data).scalar()
        # --Plaintext---

        # --sha512---
        # email
        hashed_email_data = hashlib.sha256(form.email.data.encode()).hexdigest()
        exists = False
        statement = text("SELECT * FROM users WHERE email = '{}'".format(hashed_email_data))
        results = db.engine.execute(statement)
        count = 0
        for row in results:
            count += 1
        if count >= 1:
            exists = True

        # check username
        exists2 = False
        statement = text("SELECT * FROM users WHERE username = '******'".format(form.username.data))
        results = db.engine.execute(statement)
        count = 0
        for row in results:
            count += 1
        if count >= 1:
            exists2 = True
        # --sha512---

        # bcrypt
        # hashed_email_data = bcrypt.hashpw(form.email.data.encode(), bcrypt.gensalt())
        # exists = db.session.query(User.id).filter_by(email=hashed_email_data).scalar()
        # exists2 = db.session.query(User.id).filter_by(username=form.username.data).scalar()
        # bcrypt

        if not exists and not exists2:
            # ---sha algorithm----
            # hashed_password = generate_password_hash(form.password.data, method='sha512') #with salt
            # hashed_security_Q = generate_password_hash(form.security_questions.data, method='sha1') #with salt
            # hashed_security_ans = generate_password_hash(form.security_questions_answer.data, method='sha512') #with salt
            # ---sha algorithm----

            # bcrypt
            hashed_password = bcrypt.hashpw(form.password.data.encode(), bcrypt.gensalt(rounds=16))
            hashed_security_Q = bcrypt.hashpw(form.security_questions.data.encode(), bcrypt.gensalt())
            hashed_security_ans = bcrypt.hashpw(form.security_questions_answer.data.encode(), bcrypt.gensalt())
            # bcrypt

            # password=form.password.data
            newuser = User(public_id=str(uuid.uuid4()), username=form.username.data, email=hashed_email_data,
                           password=hashed_password,
                           security_questions=hashed_security_Q,
                           security_questions_answer=hashed_security_ans,
                           is_active=True, is_authenticated=False, is_admin=False)
            # newuser = User(public_id=str(uuid.uuid4()),username=form.username.data, email=form.email.data, password=hashed_password,
            #                security_questions=form.security_questions.data,
            #                security_questions_answer=form.security_questions_answer.data,
            #                is_active=True, is_authenticated=False, is_admin=False)

            # Role.create('customer')
            # newuser.roles.append(Role(name='customer', id=2))
            # newuser.set_password(form.password.data)
            db.session.add(newuser)
            db.session.commit()
            flash("You have successfully signed up!")
            return redirect(url_for('login'))

        if exists:
            flash("Email exists!")
        if exists2:
            flash("Username is taken!")
        return redirect(url_for('signup'))
    return render_template('sign up.html', title="Sign Up", form=form)