def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        employee = Employee(Employeenumber=form.employeeNumber.data,
                            EmployeeName=form.employeeName.data,
                            EmployeeAddress=form.employeeAddress.data,
                            EmployeeCity=form.employeeCity.data,
                            EmployeeState=form.employeeState.data,
                            EmployeeZip=form.employeeZip.data,
                            EmployeeBirthDate=form.employeeBirthDate.data,
                            DepartmentID=form.employeeDepartmentID.data)
        db.session.add(employee)
        db.session.commit()
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        print(hashed_password)
        loginid = Login(LoginID=form.loginid.data,
                        Employeenumber=form.employeeNumber.data,
                        Password=hashed_password)
        db.session.add(loginid)
        db.session.commit()
        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Esempio n. 2
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        user = User(username=form.username.data, email=form.email.data, password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Your account has been created! You are now able to log in', 'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Esempio n. 3
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('choices'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')
        Employee = employee(firstName=form.firstName.data,lastName=form.lastName.data,username=form.username.data,password=hashed_password,phoneNumber = form.phone.data,email = form.email.data,roleName = form.position.data , verified= False)
        db.session.add(Employee)
        db.session.commit()
        flash('Your account has been created! You are now able to log in', 'success')
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Esempio n. 4
0
def guestCheckout(total):
    form = guestCheckoutForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = Users(name=form.name.data,
                     address=form.address.data,
                     password=hashed_password)
        db.session.add(user)
        db.session.commit()

        return redirect(url_for('home'))
    return render_template('guestCheckOut.html', form=form, total=total)
Esempio n. 5
0
def changepass():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        try:
            Employee = employee.query.filter_by(employeeID = current_user.employeeID).first()
            if Employee and bcrypt.check_password_hash(Employee.password, form.oldpassword.data):
                hashed_password = bcrypt.generate_password_hash(form.newpassword.data).decode('utf-8')
                Employee.password = hashed_password
                db.session.commit()
                flash("Password modified!","success") #why flash does not work?
                return redirect(url_for('manageacc'))
        except:
            flash("Password change not successful","danger")
    return render_template("changepass.html",form=form)
Esempio n. 6
0
def registration():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(fname=form.fname.data,
                    lname=form.lname.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash(f'Welcome, {form.fname.data}!', 'success')
        return redirect(url_for('login'))
    return render_template("registration.html",
                           title="Registration",
                           form=form)
Esempio n. 7
0
def forgotpass():
    form = ForgetForm()
    if form.validate_on_submit():
        num = randint(100000, 999999)
        hashed_password = bcrypt.generate_password_hash(str(num)).decode('utf-8')
        Employee = employee.query.filter_by(email=form.email.data).first()
        Employee.password = hashed_password
        print(num)
        db.session.commit()
        try:
            text = ("Hello there,\n Here is your temporary password: \n"+ str(num) +"\n"+
          "Please sign in using this temporary password, and modify your password in Manage Account")
            emailsend("Good News Partner - Temporary Password",form.email.data,text)
            flash("Temporary Password Sent! Please check your email","success")
            return redirect(url_for('login'))
        except:
            flash("Not Successful in sending link","danger")
    return render_template('forgot.html',form=form)
Esempio n. 8
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User1(UName=form.uname.data,
                     FName=form.firstname.data,
                     LName=form.lastname.data,
                     DOB=form.dateofbirth.data,
                     Email=form.email.data,
                     Password=hashed_password,
                     User1_type_id=form.user1typeid.data,
                     Address=form.address.data)
        # user = User1(username=form.username.data, Email=form.email.data, Password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('Your account has been created! You are now able to log in',
              'success')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Esempio n. 9
0
def register():
    vid = request.args.get('vid')
    pickup = request.args.get('pickup')
    dropoff = request.args.get('dropoff')
    dateFrom = request.args.get('dateFrom')
    dateTo = request.args.get('dateTo')
    dateT = datetime.strptime("{}".format(dateTo), "%Y-%m-%d %H:%M:%S")
    dateF = datetime.strptime("{}".format(dateFrom), "%Y-%m-%d %H:%M:%S")
    diff = abs((dateF - dateT).days)
    car = Vehicle.query.get_or_404(vid)
    amount = diff * car.rate
    tax = Decimal(amount) * Decimal(0.1)
    total = amount + tax

    form = RegistrationForm()
    if current_user.is_authenticated:
        customer = Customer.query.filter_by(email=current_user.email).first()
        reservation = Reservation(customerID=current_user.customerID,
                                  vehicleID=vid,
                                  dateFrom=dateFrom,
                                  dateTo=dateTo,
                                  pickupLocation=pickup,
                                  dropoffLocation=dropoff)
        flash('Your car has been reserved!', 'success')
        db.session.add(reservation)
        db.session.commit()
        return redirect(url_for('home'))

    # """
    # if current_user.is_authenticated:
    #     return redirect(url_for('home'))
    #     datetime.datetime.strptime("{}, {}".format(date, time), "%m-%d-%Y, %H:%M")
    #     """

    elif form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        customer = Customer(username=form.username.data,
                            email=form.email.data,
                            password=hashed_password,
                            fullName=form.fullname.data,
                            phoneNumber=form.phonenumber.data)
        db.session.add(customer)
        db.session.commit()
        customer = Customer.query.filter_by(email=form.email.data).first()
        reservation = Reservation(customerID=customer.customerID,
                                  vehicleID=vid,
                                  dateFrom=dateFrom,
                                  dateTo=dateTo,
                                  pickupLocation=pickup,
                                  dropoffLocation=dropoff)
        db.session.add(reservation)
        db.session.commit()
        flash('Your car has been reserved and account has been created!',
              'success')
        return redirect(url_for('home'))
    return render_template('register.html',
                           title='Register',
                           form=form,
                           car=car,
                           dateTo=dateTo,
                           dateFrom=dateFrom,
                           diff=diff,
                           amount=amount,
                           tax=tax,
                           total=total)