Esempio n. 1
0
    def register_view(self):
        form = RegistrationForm(request.form)
        if admin_helpers.validate_form_on_submit(form):
            adminuser = AdminUser()

            form.populate_obj(adminuser)

            adminuser.password = generate_password_hash(form.password.data)

            db.session.add(adminuser)

            try:
                db.session.commit()
            except:
                db.session.rollback()

            login.login_user(adminuser)
            return redirect(url_for('.index'))
        return self.render("admin/register.html", form=form)
Esempio n. 2
0
def sign_up(request):
    if request.method == "GET":
        return render(request, 'signUp.html')
    if request.method == "POST":
        account = request.POST.get('account', None)
        password = request.POST.get('password', None)
        real_name = request.POST.get('realName', None)
        nickname = request.POST.get('nickname', None)
        phone = request.POST.get('phone', None)
        if not account or not password or not real_name or not nickname or not phone:
            return JsonResponse(resultMsg['NeedParameter'])
        is_exist = AdminUser.objects(account=account).filter().count()
        if is_exist:
            return JsonResponse(resultMsg['ExistUser'])
        admin_user = AdminUser()
        admin_user.account = account
        admin_user.password = password
        admin_user.realName = real_name
        admin_user.nickname = nickname
        admin_user.phone = phone
        admin_user.save()
        print account + "||" + password + "||" + real_name
        return JsonResponse(resultMsg['SignUpSuccess'])