示例#1
0
def signup_page(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            email    = form.cleaned_data['email']
            user = User.objects.create_user( username,
                    email,
                    password
                    )
            user.save()
            request.session.flush()
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect("/")
            return HttpResponseRedirect("/")
        else:
            return HttpResponseRedirect("/signup/")
    if request.method == "GET":
        form = SignupForm()
        return render(request, 'signup.html', {
            'title': 'Регистрация нового пользователя',
            'form': form, 
            'button-text': 'Регистировать',
        })
示例#2
0
文件: views.py 项目: noknod/sm_web
def signup(request):
    error = ''
    if request.method == 'POST':
        form = SignupForm(request.POST)
        user = None
        form.is_valid()
        try:
            user = form.save()
            user = authenticate(username=request.POST['username'], password=request.POST['password'])
            login(request, user)
        except Exception as e:
            error = 'not created:\n' + str(e)
            traceback.print_exc()
        else:
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'error': error, 'form': form})
示例#3
0
文件: views.py 项目: StealthyFox/web
def user_signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')
    form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#4
0
def user_signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')
    form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#5
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            u = form.save()
            url = '/'
            authlogin(request, u)
            return HttpResponseRedirect(url)
    else:
        form = SignupForm()
    return render(request, 'qa/signup.html', {'form': form})
示例#6
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            form.clean()
            user = form.save()
            login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'qa/signup.html', {'form': form})
示例#7
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            auth_login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()

    return render(request, 'signup_template.html', {'form': form})
示例#8
0
文件: views.py 项目: shadchin/stepic
def singup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#9
0
def singup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#10
0
文件: views.py 项目: a-shar/web_tech
def signup(request, *args, **kwargs):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect("/")

    else:
        form = SignupForm()

    return render(request, 'accounts/signup.html', {
        'form': form
    })
示例#11
0
def signup(request):
	if request.method == 'POST':
		form = SignupForm(request.POST)
		if form.is_valid():
			user = form.save()
			request.session.flush()
			request.session['user'] = user.id
			return HttpResponseRedirect('/')
	else:
		form = SignupForm()
	return render(request, 'signup_form.html', {
		'form': form,
	})
示例#12
0
文件: views.py 项目: Kantair/test1
def signup(request) :
	if request.method == "POST" :
		form = SignupForm(request.POST)
		if form.is_valid() :
			form.save()
			#user = form.loginUser()
			user = authenticate(username=request.POST['username'], password=request.POST['password'])
			login(request, user)
			return HttpResponseRedirect("/")
	else :
		form = SignupForm()
	return render(request, 'ask_add.html', {
		'form' : form,
	})
示例#13
0
文件: views.py 项目: mike1994s/web
def signup(request):
	user = request.user
        if user.is_authenticated():
                return HttpResponseRedirect("/")
	if request.method == "POST":
        	form = SignupForm(request.POST)
                if form.is_valid():
			new_user = form.save(request)
                        return HttpResponseRedirect("/")
        else:
                        form = SignupForm()
        return render(request, 'qa/formsignup.html', {
                'form': form
})
示例#14
0
文件: views.py 项目: natalizav/stepic
def signup(request):
	if request.method == 'POST':
		form = SignupForm(request.POST)
		p = request.POST
		if form.is_valid():
			User.objects.create_user(username=p.get('username'), email=p.get('email'), password=p.get('password'))
			user = authenticate(username=p.get('username'), password=p.get('password'))
			login(request, user)
			return HttpResponseRedirect('/')
	else:
		form = SignupForm()
	return render(request, 'signup.html', {
		'form': form,
	})
示例#15
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            user = authenticate(username=form.cleaned_data['username'],
                                password=form.cleaned_data['password'])
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#16
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            user = authenticate(**form.cleaned_data)
            if user:
                login(request, user)
                return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
    })
示例#17
0
def signup(request):
    error = ''
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            response = HttpResponseRedirect('/')
            # response.set_cookie('sessionid', key, path='/', expires=datetime.now()+timedelta(days=5))
            return response
        else:
            error = form.errors
    form = SignupForm()
    return render(request, 'qa/signup.html', {'form': form, 'error': error})
示例#18
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            user = authenticate(username=user.username, password=request.POST['password1'])
            if user is not None and user.is_active:
                login(request, user)
                return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'qa/signup.html', {
        'form': form
    })
示例#19
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save(request)
            if user != None:
                resp = HttpResponseRedirect('/') #Replace to request.next
                return resp	
    else:
        form = SignupForm()
            
    return render(request, 'signup.html', {
                'form': form,
        })
示例#20
0
def signup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')
    form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
        'user': request.user,
        'session': request.session,
    })
示例#21
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save(request)
            if user != None:
                resp = HttpResponseRedirect('/')  #Replace to request.next
                return resp
    else:
        form = SignupForm()

    return render(request, 'signup.html', {
        'form': form,
    })
示例#22
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = form.cleaned_data['username']
            password = form.raw_passwrd
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
            return HttpResponseRedirect(reverse('index'))
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form})
示例#23
0
def signup(request, *args, **kwargs):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            sessionid = create_session(user)
            url = request.POST.get('continue', '/')
            response = HttpResponseRedirect(url)
            response.set_cookie('sessionid', sessionid)
            return response
    else:
        form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
    })
示例#24
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        username = request.POST['username']
        password = request.POST['password']
        if form.is_valid():
            user_new = form.save()
            user = authenticate(username=username, password=password)
            if user is not None:
                login(request, user)
                return HttpResponseRedirect(reverse('questions_new'))
    else:
        form = SignupForm()

    return render(request, 'registration/signup.html', {"form": form})
示例#25
0
 def post(self,request):
     bound_form=SignupForm(request.POST)
     if bound_form.is_valid():
         if bound_form.save():
             url=request.POST.get ('continue','/')
             response=HttpResponseRedirect(url)
             sessid=CustomUser.objects.do_login(bound_form.cleaned_data['username'],bound_form.cleaned_data['password'])
             response.set_cookie('sessid', sessid,
             domain='127.0.0.1',httponly=True,
             expires=timezone.datetime.now()+timezone.timedelta(days=5)
             )
         
         return response
     else:
         return render (request, 'qa/signup.html',context={'form': bound_form})
示例#26
0
文件: views.py 项目: MelroiN/web_test
def signup(request):
	if request.method == "POST":
		form = SignupForm(request.POST)
		if form.is_valid():
			form.save()
			user = authenticate(username=request.POST.get('username'), password = request.POST.get('password'))
			#user = form.save()
			if user is not None and user.is_active:
				login(request,user)
				return HttpResponseRedirect("/")
	else:
		form = SignupForm()
	return render(request, 'qa/signup.html', {
		'form': form
	})
示例#27
0
文件: views.py 项目: zmozg/web
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            form.save()
            username = request.POST['username']
            password = request.POST['password']
            user = auth.authenticate(username=username, password=password)
            if user is not None and user.is_active:
                auth.login(request, user)
                return HttpResponseRedirect('/')
            return HttpResponseRedirect('/signup.html')
    else:
        form = SignupForm()
    return render(request, 'qa/signup.html', {'form': form})
示例#28
0
def signup(request):
    """Signup view."""
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            auth_user = authenticate(username=user.username,
                                     password=form.cleaned_data['password'])
            login(request, auth_user)
            return HttpResponseRedirect(reverse('root', kwargs={}))
    else:
        form = SignupForm()

    context = {'form': form}
    return render(request, 'signup.html', context)
示例#29
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            form.save()
            username = request.POST.get('username')
            password = request.POST.get('password')
            user = authenticate(username=username, password=password)
            login(request, user)
            url = request.POST.get('continue', '/')
            return HttpResponseRedirect(url)

    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form})
def signup_add(request):
   #logger.debug(request)
   if request.method == 'POST': 
      #logger.debug('signup_add:' + request.method)
      form = SignupForm(request.POST)
      #logger.debug('signup_add POST:' + request.POST['username'] + ',pass='******'password']+ ',email=' + request.POST['email'])
      if form.is_valid():
        #logger.debug('signup_add form.is_valid:')
        user = form.save()
        if user is not None:
          login(request,user)
          #logger.debug('signup_add login')
          return HttpResponseRedirect('/')

   form = SignupForm()
   return render(request, 'signup.html', {'form': form,})
示例#31
0
def user_sign(request):
    """With a GET request, a form for entering data should be displayed,
    with a POST request a new user is created, the user created is logged in to the site,
    the redirect is returned to the main page. The user must receive an authorization cookie

    """
    form = SignupForm(request.POST)
    if request.method == 'POST' and form.is_valid():
        user = form.save()
        if user is not None:
            login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
    })
def signup(request):
    form = SignupForm(request.POST or None)

    if form.is_valid():
        try:
            user = form.save()
        except:
            user = None

        if user != None:
            logout(request)
            login(request, user)
            return HttpResponseRedirect("/")
        else:
            request.session["register_error"] = 1

    return render(request, "signup.html", {"form": form})
示例#33
0
def signupView(request, *args, **kwargs):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            username = request.POST['username']
            password = request.POST['password']
            email = request.POST['email']
            user = User.objects.create_user(username=username, email=email, password=password)
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()

    return render(request, 'login-signup-template.html', {'form': form, 'title': 'Signup', 'signup': True})
示例#34
0
def signup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = form.cleaned_data["username"]
            password = form.raw_passeord
            user = authenticate(username=username, password=password)
            print(type(user))
            if user is not None:
                if user.is_active:
                    login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form,
                                           'user': request.user,
                                           'session': request.session, })
示例#35
0
def signup(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
        'user': request.user,
        'session': request.session,
    })
示例#36
0
文件: views.py 项目: nekorro/stepic16
def user_signup(request, *args, **kwargs):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            url = '/'
            sessionid = do_login(user.username, user.password)
            response = HttpResponseRedirect(url)
            response.set_cookie('sessionid', sessionid,
                domain='127.0.0.1', path='/', httponly=True,
                expires=datetime.now()+timedelta(days=5)
                )
            return response
    else:
        form = SignupForm()
    return render(request, 'qa/signup.html',{
        'form': form,
        })
示例#37
0
def signup_add(request):
    # logger.debug(request)
    if request.method == 'POST':
        # logger.debug('signup_add:' + request.method)
        form = SignupForm(request.POST)
        # logger.debug('signup_add POST:' + request.POST['username'] + ',pass='******'password']+ ',email=' + request.POST['email'])
        if form.is_valid():
            # logger.debug('signup_add form.is_valid:')
            user = form.save()
        if user is not None:
            login(request, user)
            # logger.debug('signup_add login')
            return HttpResponseRedirect('/')

    form = SignupForm()
    return render(request, 'signup.html', {
        'form': form,
    })
示例#38
0
def signup_form(request):
  #if request.user.is_authenticated():
	#	return HttpResponseRedirect('/'); 
  if request.method == "POST":
    form = SignupForm(request.POST)
    if form.is_valid():
      user = form.save()
      user = authenticate(username=user.username, password=form.cleaned_data['password'])
      if user is not None:
        if user.is_active:
          login(request, user)
          return HttpResponseRedirect('/')
  else:
    form = SignupForm()
  return render(request, 'signupform.html', {
    'form': form,
    'path': request.path,
  })
示例#39
0
def user_add(request):
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            login = request.POST.get('username')
            password = request.POST.get('password')
            user = form.save()
            url = request.POST.get('continue', '/')
            sessid = do_login(login, password)
            if sessid:
                response = HttpResponseRedirect(url)
                response.set_cookie('sessionid', sessid)
                return response
    else:
        form = SignupForm()
    return render(request, 'registration.html', {
        'form': form,
    })
示例#40
0
def signup(request):
    logger.error(request.body)
    if request.method == 'POST':
        form = SignupForm(request.POST)
        username = request.POST.get('username')
        password = request.POST.get('password')
        if form.is_valid():
            user_new = form.save()
            user = authenticate(username=username, password=password)
            if user is not None:
                login(request, user)
                # return HttpResponseRedirect(reverse('last_questions_list'))
    else:
        form = SignupForm()

    return render(request, 'registration/signup.html', {
        "form": form
    })
示例#41
0
文件: views.py 项目: gavrigor/swp
def signup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            user = form.save()
            username = form.cleaned_data["username"]
            password = form.raw_passeord
            user = authenticate(username=username, password=password)
            print(type(user))
            if user is not None:
                if user.is_active:
                    login(request, user)
            return HttpResponseRedirect('/')
    else:
        form = SignupForm()
    return render(request, 'signup.html', {'form': form,
                                           'user': request.user,
                                           'session': request.session, })
示例#42
0
文件: views.py 项目: aatl/stepic_web
def signupHandler(request):

    if request.POST:
        form = SignupForm(request.POST)
        if form.is_valid():
            new_user = form.save()

            username = request.POST['username']
            password = request.POST['password']
            user = auth.authenticate(username= username, password= password)
            if user is not None:
                auth.login(request, user)
                return HttpResponseRedirect('/')
    else:
        form = SignupForm()

    return render(request, 'signupTemplate.html', {
        'signupForm': form,

    })
示例#43
0
def signup_page(request):

    if request.method == "POST":

        form = SignupForm(request.POST)

        if form.is_valid():

            user = User.objects.create_user( form.cleaned_data["username"],

                    form.cleaned_data["email"],

                    form.cleaned_data["password"]

                    )

            user.save()

            request.session.flush()

            request.session['signup']=user.username

            return HttpResponseRedirect("/")

        else:

            return HttpResponseRedirect("/signup/")

    if request.method == "GET":

        form = SignupForm()

        return render(request, 'signup.html', {

            'title': 'New reg',

            'form': form, 

            'button-text': 'Reg',

        })
示例#44
0
def signup(request) :
	if request.method == "POST" :
		form = SignupForm(request.POST)
		if form.is_valid() :
			#print("POST!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
			#print("username: "******"username") + "!")
			#print("password: "******"password") + "!")
			#print("email: " + request.POST.get("email") + "!")
			form.set_password(request.POST.get("password"))
			user = form.save()
			#print("SAVE USER!!!!!!!!!!!!!!!!!!!!!!!")
			#print("username: "******" !")
			#print("password: "******" !")
			#print("email: " + user.email + " !")
			form.loginUser(request)
			return HttpResponseRedirect("/")
	else :
		form = SignupForm()
	return render(request, 'ask_add.html', {
		'form' : form,
	})
def signup(request):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid():
            # print("POST!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
            # print("username: "******"username") + "!")
            # print("password: "******"password") + "!")
            # print("email: " + request.POST.get("email") + "!")
            form.set_password(request.POST.get("password"))
            user = form.save()
            # print("SAVE USER!!!!!!!!!!!!!!!!!!!!!!!")
            # print("username: "******" !")
            # print("password: "******" !")
            # print("email: " + user.email + " !")
            form.loginUser(request)
            return HttpResponseRedirect("/")
    else:
        form = SignupForm()
    return render(request, 'ask_add.html', {
        'form': form,
    })
示例#46
0
def vsignup(request):
    vlogout(request)
    if request.method=='POST':
       form=SignupForm(request.POST)
       if form.is_valid():
          user=form.save()
          username=request.POST.get('username')
          moi_password=request.POST.get('password')
          user=authenticate(username=username,password=moi_password)
          if user is not None:
             if user.is_active:
                login(request,user)
             else:
                return HttpResponse('User None')
          else:
             pass
          return HttpResponseRedirect('/')
    else:
       form=SignupForm()
    return render(request,'signup.html',{'form': form,
                                         'user': request.user,
    })
示例#47
0
def signup(request, *args, **kwargs):
    if request.method == "POST":
        form = SignupForm(request.POST)
        if form.is_valid() == True:
            form.save()
            my_username = form.cleaned_data['username']
            my_password = form.cleaned_data['password']
            user = authenticate(username=my_username, password=my_password)
            login(request, user)
            print('User %s is created!' % my_username)
            url = '/'
            return HttpResponseRedirect(url)
        else:
            return render(request, 'signup.html', {
                'form': form,
                'is_user': False,
            })
    else:
        form = SignupForm()
        return render(request, 'signup.html', {
            'form': form,
            'is_user': False,
        })