Exemple #1
0
def registerByAdmin():
    form = signupForm()
    if request.method == 'POST':
        email = form.email.data
        password = form.password.data
        name = form.name.data
        last = form.last.data
        Admin = form.Admin.data
        user = auth.create_user_with_email_and_password(email, password)
        if Admin == 'true':
            data = {
                "name": name,
                "last": last,
                "email": email,
                "password": password,
                "admin": True
            }
        if Admin == 'false':
            data = {
                "name": name,
                "last": last,
                "email": email,
                "password": password,
                "admin": False
            }
        print(auth.get_account_info(user['idToken'])['users'][0]['localId'])
        info = auth.get_account_info(user['idToken'])['users'][0]['localId']
        db.collection(u'Users').document(info).set(data)
        return redirect(url_for("login"))

    return render_template('signup.html', form=form, us="Not Exist")
Exemple #2
0
def signup():
    celery = create_celery(current_app)
    form = signupForm()
    if form.validate_on_submit():
        try:
            user = User(form.email.data, form.password.data)
            db.session.add(user)
            db.session.commit()
            token = gen_confirmation_token(user.email)
            confirm_url = url_for('user.confirm_email',
                                  token=token,
                                  _external=True)
            html = render_template('user/email/activate.html',
                                   confirm_url=confirm_url)
            sub = "From FuturesDataStore - activate your account"
            celery.send_task('tasks.send_mail', args=(sub, user.email, html))
            flash('Check your inbox to activate your account.', 'success')
            return redirect(url_for('main.home'))
        except IntegrityError:
            db.session.rollback()
            flash('ERROR! Email {} already exists.'.format(form.email.data),
                  'error')
    return render_template('user/signup.html',
                           form=form,
                           current_user=current_user,
                           title='Sign Up')
Exemple #3
0
def signup():
    error = None
    # password = request.form.get['password']
    # vpassword = request.form.get['vpassword']

    form = signupForm()

    if request.method == 'POST':
        if form.validate == False:
            return render_template("user-signup.html", form=form)
        else:
            if request.form['password'] != request.form['vpassword']:
                # error = 'Password must match'
                flash('Passwords must match!')
                return redirect(url_for('signup'))
            elif len(request.form['password']) < 3 or len(
                    request.form['password']) > 20:
                flash('password must between 3 or 20 characters!')
                return redirect(url_for('signup'))
            elif ' ' in (request.form['password']).strip() == True:
                flash('No spaces allowed!')
                return redirect(url_for('signup'))
            elif ' ' in (request.form['user_name']).strip() == True:
                flash('No spaces allowed in username!')
                return redirect(url_for('signup'))
            elif len(request.form['user_name']) < 3 or len(
                    request.form['user_name']) > 20:
                flash('username must between 3 or 20 characters!')
                return redirect(url_for('signup'))
            else:
                return 'Welcome, ' + request.form['user_name']
    elif request.method == 'GET':
        return render_template("user-signup.html", form=form, error=error)
Exemple #4
0
def signup():
    orgName = request.form.get('orgs')  # Return the org selected by user
    orgID = db.session.query(
        classDict['ORG']).filter(classDict['ORG'].ORG_NAME == orgName)[0].ID

    form = signupForm()
    errors = []

    if form.validate_on_submit():
        data = form.data
        mngrID = data['mngrID']
        pswd = data['pswd']
        cpswd = data['cpswd']
        email = data['email']
        key = data['key']
        # Check if manager ID or email already exists in org
        qManager = db.session.query(
            classDict['MANAGER']).filter(classDict['MANAGER'].ORG_ID == orgID)
        mngrIDs = []
        emailIDs = []
        for row in qManager:
            mngrIDs.append(row.USERNAME)
            emailIDs.append(row.EMAIL_ID)
            keys.append(row.ORG_KEY)
        if mngrID in mngrIDs:
            errors.append(
                "This manager ID already exists in this organization.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))
        if email in emailIDs:
            errors.append("This email ID already exists in this organization.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # Check key
        orgKey = db.session.query(orgClass).filter(
            orgClass.ORG_ID == orgID)[0].ORG_KEY
        if key != orgKey:
            errors.append("The key does not match the organization key.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # Check if password and confirm password fields match
        if pswd != cpswd:
            errors.append("The passwords do not match. Please try again.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # If all checks pass, insert SQL
        manager.addManager(userName=mngrID,
                           pswd=pswd,
                           email=email,
                           orgID=orgID)

        errors.append("Manager is Registered! Please login."
                      )  # Reuse errors page for successful registration also
        return render_template('generic_text.html',
                               error=Markup("<br/>".join(errors)))

    return render_template('signup.html', form=form)
Exemple #5
0
def login():
    form = signupForm()
    # if user click submit on signup page
    if form.validate_on_submit():
        some_id = form.uid.data
        uid = sql_actions.check_user(db, some_id)
        if uid == -1:
            flash('This userID does not exist, Please try again', 'error')
            return redirect(url_for('login'))
        return redirect(url_for('dashboard', uid=some_id))
    return render_template('login.html', form=form)
Exemple #6
0
def login():
    orgName = request.form.get('orgs')  # Return the org selected by user
    orgID = db.session.query(
        classDict['ORG']).filter(classDict['ORG'].ORG_NAME == orgName)[0].ID

    form = signupForm()
    errors = []

    if form.validate_on_submit():
        data = form.data
        mngrID = data['mngrID']
        pswd = data['pswd']
        key = data['key']
        # Check if manager ID or email already exists in org
        qManager = db.session.query(
            classDict['MANAGER']).filter(classDict['MANAGER'].ORG_ID == orgID)
        mngrIDs = []
        for row in qManager:
            mngrIDs.append(row.USERNAME)
            keys.append(row.ORG_KEY)
        if mngrID not in mngrIDs:
            errors.append(
                "This manager ID does not exist in this organization.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # Check key
        orgKey = db.session.query(orgClass).filter(
            orgClass.ORG_ID == orgID)[0].ORG_KEY
        if key != orgKey:
            errors.append("The key does not match the organization key.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # Check pswd
        truepswd = db.session.query(classDict['MANAGER']).filter(
            classDict['MANAGER'].ORG_ID == orgID).filter(
                classDict['MANAGER'].USERNAME == mngrID)[0].PASSWORD
        if pswd != truepswd:
            errors.append("The password is incorrect.")
            return render_template('generic_text.html',
                                   error=Markup("<br/>".join(errors)))

        # If all checks pass
        # run a dashboard function thatn pulls all info of this user and then push it to dashboard.html
        # Example:
        results = getDashboard(orgID, mngrID)

        return render_template('dashboard.html')

    return render_template('login.html', form=form)
Exemple #7
0
def signup():
    form=signupForm()
    if request.method == 'POST':
        email=form.email.data
        password=form.password.data
        name=form.name.data
        last=form.last.data
        user=auth.create_user_with_email_and_password(email,password)
        data={"name":name,"last":last,"email":email,"password":password,"admin":False}
        #db.child("Guest").push(data)
        #data2={"name":"1","other":email,"shadowing":"123"}
        #db.child("Parks").push(data2)
        print(auth.get_account_info(user['idToken'])['users'][0]['localId'])
        info=auth.get_account_info(user['idToken'])['users'][0]['localId']
        db.collection(u'Users').document(info).set(data)
        return redirect(url_for("home"))
    return render_template('signup.html',form=form)
Exemple #8
0
def signup():
    signupform = signupForm()
    if request.method == 'POST':
        users = mongo.db.users
        existingUser = users.find_one({'username': request.form['username']})
        if existingUser is None:
            hashpass = bcrypt.hashpw(request.form['password'].encode('utf-8'),
                                     bcrypt.gensalt())
            users.insert({
                'username': request.form['username'],
                'password': hashpass
            })
            session['username'] = request.form['username']
            return redirect(url_for('home'))

        flash('That username already exists')

    return render_template('signup.html', form=signupform)
Exemple #9
0
def signup():
    error = None
    form = signupForm()

    if request.method == 'POST' and form.validate():
        user = User.query.filter_by(username=form.name.data).first()
        if user is not None:
            error = 'Username not available'
        else:
            user = User(form.name.data, form.password.data)
            db.session.add(user)
            db.session.commit()
            session['logged_in'] = True
            session['user_id'] = user.id
            session['name'] = user.username
            return redirect(url_for('index')), 201

    return render_template('signup.html', error=error, form=form), 200
Exemple #10
0
def signup():
    if 'email' in session:
        return redirect(url_for('home'))

    form = signupForm()
    if request.method == "POST":
        if form.validate() == False:
            return render_template('signup.html', form=form)
        else:
            newuser = User(form.first_name.data, form.last_name.data,
                           form.email.data, form.password.data)
            db.session.add(newuser)
            db.session.commit()

            session['email'] = newuser.email
            return redirect(url_for('home'))
    elif request.method == "GET":
        return render_template('signup.html', form=form)
Exemple #11
0
def signup():
	form = signupForm(request.form)
	form_data = str({request.form['username'],
				 request.form['password'],
				 request.form['email'],
				 request.form['number'],
				 request.form['user_option']}).encode('utf-16')
	
	if request.method == 'POST':
	
		#For Server
		text_file = open('/var/www/wob/signup_entries.txt', 'a')
		#For Local
		#text_file = open('email_entries.txt', 'a')
		text_file.write('\n %s' % form_data )
		text_file.close()
		
		#*******************************************************#
		# // FOR EMAIL //
		msg = Message("New Signup from user!",
			  sender="*****@*****.**",
			  recipients=["*****@*****.**"])	
		msg.body = form_data
		mail.send(msg)
		
		return redirect(url_for('waiting'))
	
	'''
	
		#*******************************************************#
		enter_signup = User(request.form['username'],
				    request.form['password'],
				    request.form['email'],
				    request.form['number'],
				    request.form['user_option'])
		db.session.add(enter_signup)
		db.session.commit()
		return redirect(url_for('login'))
		
	'''	
		
	return render_template('sign_up.html')
Exemple #12
0
def signup():
    if 'Ses' in session:
        return redirect(url_for('home'))

    form = signupForm()
    if request.method == "POST":
        if form.validate() == False:
            return render_template("signup.html", form=form)
        else:
            newuser = User(form.First_Name.data, form.Last_Name.data,
                           form.Email.data, form.Password.data)
            db.session.add(newuser)
            db.session.commit()
            session['Ses'] = newuser.Email
            session['welcome'] = newuser.First_Name
            session['last'] = newuser.Last_Name
            return redirect(url_for('home'))

    elif request.method == "GET":
        return render_template("signup.html", form=form)
Exemple #13
0
def signup():
	print "entering signup form"
	if g.user is not None and g.user.is_authenticated():
		return redirect(url_for('index'))
	form = signupForm()
	if form.validate_on_submit():
		print "new user signing up"
		print "email = " + form.email.data
		print "password = "******"user successfully added to DB"
		login_user(u)
		return redirect(url_for('index'))
	else:
		print "form.validate did not execute"
	return render_template('signup.html',
							title = "Sign Up", 
							form = form)
Exemple #14
0
def registerScrumMaster():
    form = signupForm()
    if request.method == 'POST':
        email = form.email.data
        password = form.password.data
        id = form.id.data
        firstname = form.firstname.data
        lastname = form.lastname.data
        try:
            Developertabel = auth.create_user_with_email_and_password(
                email, password)
            data = {
                "email": email,
                "password": password,
                "id": id,
                "firstname": firstname,
                "lastname": lastname
            }
            db.collection(u'ScrumMastertabel').document().set({
                "email":
                email,
                "password":
                password,
                "id":
                id,
                "firstname":
                firstname,
                "lastname":
                lastname
            })
            print(
                auth.get_account_info(userregisterScrumMaste['idToken'])
                ['ScrumMastertabel'][0]['localId'])
            info = auth.get_account_info(userregisterScrumMaste['idToken']
                                         )['ScrumMastertabell'][0]['localId']
            db.collection(u'ScrumMastertabel').document(info).set(data)
            #return redirect(url_for("scrumMasterPage"),form=form)
            return render_template('scrumMaster.html', form=form)
        except:
            print("email already exist")
    return render_template('registerScrumMaster.html', form=form)
Exemple #15
0
def register():
    form = signupForm()
    if form.validate_on_submit():
        """
			INSTANTIATE NEW USER
			HASH USER PASSWORD
			INSERT AND COMMIT USER RECORD TO DATABASE
		"""
        new_user = User(firstName=form.firstName.data,
                        lastName=form.lastName.data,
                        username=form.username.data)
        new_user.set_password(form.password.data)
        db.session.add(new_user)
        db.session.commit()
        db.session.close()
        """
			ALERT USER OF PROPER REGISTRATION
		"""

        flash("Account Created! Let's Begin Studying!", "success")
        return redirect(url_for("main"))
    return render_template("signup.html", form=form)
Exemple #16
0
def signup():
    form = signupForm()
    search = searchForm()
    date = datetime.strftime(datetime.now(), '%d/%m/%Y')
    categories = Category.query.all()
    if form.validate_on_submit():
        user = User()
        user.username = form.username.data.strip()
        if db.session.query(User).filter_by(username=user.username).first():
            flash(f'"{user.username}" username already taken.')
            return redirect( url_for('signup'))
        user.full_name = form.full_name.data.strip()
        user.email = form.email.data.strip()
        if db.session.query(User).filter_by(email=user.email).first():
            flash(f'"{user.email}" email already taken.')
            return redirect(url_for('signup'))
        user.bio = form.bio.data.strip()
        user.dob = form.dob.data.strip()
        user.password = generate_password_hash(form.password.data.strip(), method='sha256')
        db.session.add(user)
        db.session.commit()
        flash('Registration successfull, you can now login')
        return redirect(url_for('index'))
    return render_template('signup.html', form=form, search=search, date=date, categories=categories_, current_user=current_user, cat=categories)
Exemple #17
0
def register():
    form=signupForm()
    if request.method == 'POST':
        return redirect(url_for("signup"))
    return render_template('signup.html',form=form)