Пример #1
0
def signup():
    signup_form = RegisterForm()
    context = {
        'signup_form': signup_form
    }

    if signup_form.validate_on_submit():
        username = signup_form.username.data
        password = signup_form.password.data
        # no validamos el email

        user = getUser(username)
        if user is None:
            user_data = UserData(username, password)
            newUser = user_put(user_data)

            user =  UserModel(newUser)

            login_user(user)

            flash('Bienvenido !!')

            return redirect(url_for('hello'))
        
        else:
            flash("El usuario ya existe !!")




    return render_template('signup.html', **context)
Пример #2
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, password=generate_password_hash(form.password.data))
        db.session.add(user)
        db.session.commit()
        flash('注册成功')
        return redirect(url_for('blog.index'))
    return render_template('register.html', form=form)
Пример #3
0
def register_form(request, page):
    form = RegisterForm()
    if request.method == "POST":
        form = RegisterForm(request.POST)
        if form.is_valid():
            form.save()
            redirect = request.path + "?sent=1"
            return HttpResponseRedirect(redirect)
    return {"form": form}
Пример #4
0
def register():
    form = RegisterForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            data = form.data
            user = Admin(username=data['username'], password=data['pwd'])
            db.session.add(user)
            db.session.commit()
            return redirect(url_for('admin.login'))
    return render_template('admin/register.html', form=form)
Пример #5
0
def signup():
    form = RegisterForm()

    if form.validate_on_submit():
        new_user = User(username=form.username.data, studentName = form.studentName.data, email=form.email.data, password=form.password.data, reportTally = 0)
        db.session.add(new_user)
        db.session.commit()
        flash('You are now registered!')

        return redirect(url_for('login'))

    return render_template('Registration.html', form=form, title="Register")
Пример #6
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegisterForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_pwd(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('恭喜,注册成功')
        return redirect(url_for('login'))
    return render_template('register.html', title='注册', form=form)
Пример #7
0
def register():
    registerForm = RegisterForm()
    if registerForm.validate_on_submit():
        print("hello {}".format(registerForm.email.data))
        hashed_password = bcrypt.generate_password_hash(registerForm.password.data).decode('utf-8')
        user = User(username=registerForm.username.data, email=registerForm.email.data, password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash('{} your account has been successfully created!'.format(
            registerForm.username.data))
        return redirect(url_for('home'))
    return render_template('register.html', title = 'Register', form=registerForm)
Пример #8
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'), title='Register')

    form = RegisterForm()

    if form.validate_on_submit():
        u = User(username=form.username.data,
                 fname=form.fname.data,
                 lname=form.lname.data)
        u.set_password(form.password.data)
        db.session.add(u)
        db.session.commit()
        flash('Congratulations! You have been registered!')
        return redirect(url_for('login'))
    return render_template('register.html', form=form)
Пример #9
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))

    form = RegisterForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash("You are now registered!")
        return redirect(url_for('login'))

    return render_template('register.html',
                           title="Signup - Generic website",
                           form=form)
Пример #10
0
def register():
    form = RegisterForm()
    if request.method == 'GET':
        return render_template('register.html', form=form)

    if request.method == 'POST':
        if form.validate_on_submit():
            # 验证通过
            # 验证用户是否注册,验证密码和确认密码是否一致
            user = User()
            user.username = form.username.data
            user.password = generate_password_hash(form.password.data)
            db.session.add(user)
            db.session.commit()
            return '注册成功'
        else:
            return redirect(url_for('user.register'))
Пример #11
0
def signup():
    form = RegisterForm()
    if request.method=='POST':
        user = Register(username = form.username.data, password=form.password.data,
                        email = form.email.data,
                        surname = form.surname.data,
                        name=form.name.data,        MiddleName=form.MiddleName.data,
                        birthPlace=form.birthPlace.data,
                        passport=form.passport.data
                        )
        db.session.add(user)
        db.session.commit()
        return render_template('contact.html', form=form)
    return render_template('signup.html', form=form)
Пример #12
0
def register():
    form = RegisterForm()
    status = {'status': 403}
    if form.validate_on_submit():
        u = User(userid=str(uuid1()),
                 username=form.username.data,
                 email=form.email.data,
                 mobile=form.mobile.data,
                 password=form.password.data)
        db.session.add(u)
        status['status'] = 200
        return jsonify(status)
    else:
        logging.error(form.errors)
        if 'username' in form.errors.keys():
            status['error'] = "用户名已被注册,请更换用户名后重试"
            return jsonify(status)
        elif 'email' in form.errors.keys():
            status['error'] = "邮箱已被绑定,请更换邮箱后重试"
        elif 'mobile' in form.errors.keys():
            status['error'] = "号码已被注册,请更换号码后重试"
        else:
            status['error'] = "输入信息校验失败,请稍后重试"
        return jsonify(status)
Пример #13
0
def register(request):
	# post请求表示提交数据注册
	if request.method == 'POST':

		# 提交过来的数据生成表单
		form = RegisterForm(request.POST)
		# 验证表单有没有错误,没有为True,然后进行注册处理
		if form.is_valid():

			# 业务处理(注册)(以下是获取表单的几种形式)
			# 1
			username = request.POST.get('username')
			password = request.POST.get('password')

			# 2
			# username = form.cleaned_data.get('username', '')
			# password = form.cleaned_data.get('password', '')

			# 3
			#data = request.POST.dict()

			# 保存到数据库
			user = User.objects.create(username=username, password=password)
			# user = User()
			# user.username = username
			# user.password = password
			# user.save()

			# 重定向到登录页面
			return redirect('app:login')
		else:
			# 验证不成功将错误信息返回,渲染到页面
			return render(request, 'register.html', {'form': form})

	# get请求表示来到注册页面
	return render(request, 'register.html')
Пример #14
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        if form.internal_code.data != INTERNAL_CODE:
            form.errors['internal_code'] = ["内测码错误, 请联系作者。"]
        if not form.errors:
            user = User.query.filter_by(username=form.username.data).first()
            if user:
                form.errors['username'] = [
                    '用户名 {} 已被占用'.format(form.username.data)
                ]
            else:
                user = User.query.filter_by(email=form.email.data).first()
                if user:
                    form.errors['email'] = [
                        '邮箱 {} 已被占用'.format(form.email.data)
                    ]
        if not form.errors:
            user = User(form.username.data, form.email.data,
                        form.password.data)
            if user:
                return redirect(url_for("view.login"))
    return render_template("register.html", form=form)