コード例 #1
0
def auth_login(request):
    if request.method == "GET":
        return render(request, 'member/auth_login.html')
    elif request.method == 'POST':
        id = request.POST['username']
        pw = request.POST['password']
        #DB에 인증
        obj = auth1(request, username=id, password=pw)
        if obj is not None:
            login1(request, obj)  # 세션에 추가
            return redirect("/member/auth_index")
        return redirect("/member/auth_login")
コード例 #2
0
def login(request):
    if request.method == "GET":
        form = Login()
        return render(request, "kitchen/login.html", {'form': form})
    else:
        form = Login(request.POST)
        if form.is_valid():
            print("验证成功")
            login1(request, form.user)
            return redirect(reverse('kitchen:index'))
        else:
            form = Login()
            return redirect(reverse('kitchen:login'), {'form': form})
コード例 #3
0
ファイル: views.py プロジェクト: s6470076/python_web
def auth_login(request):
    if request.method == 'GET':
        return render(request, 'member/auth_login.html')
    elif request.method == 'POST':
        id = request.POST['username']
        pw = request.POST['password']

        obj = auth1(request, username=id, password=pw)

        if obj:
            login1(request, obj)
            return redirect("/member/auth_index")

        return redirect("/member/auth_login")
コード例 #4
0
def login(request):
    if request.method == "GET":
        form = Login()
        return render(request, "login1.html", {'form': form})
    else:
        form = Login(request.POST)
        if form.is_valid():
            login1(request, form.user)
            if request.user.is_staff == 1:
                return render(request, "login1.html", {'form': form})
            else:
                return redirect(reverse("financing:index"))  # 响应
        else:
            # 重新登录
            return render(request, "login1.html", {'form': form})
コード例 #5
0
def login(request):
    if (request.method == 'POST'):
        user_name = request.POST.get('username')
        password = request.POST.get('password')
        user1 = authenticate(username=user_name, password=password)

        if user1 is not None:
            login1(request, user1)

            if CompanyRegister.objects.filter(user=user1):
                return render(request, 'company/companydashboard.html',
                              {'username': user_name})
            elif UserRegister.objects.filter(user=user1):
                return render(request, 'candidate/dasboard.html',
                              {'username': user_name})
    else:
        return render(request, 'login.html')
コード例 #6
0
ファイル: client.py プロジェクト: jliev/wealthbot_chatterbot
def registration0(request, ria_id):
	# If the user already logged-in,, then redirect to page to continue registration
	# Check if the ria_id exists in users table or not

	ria = get_object_or_404(User, pk=ria_id)
	# And if exists, then check if ria_id has valid role or not
	if not ria.hasRole('ROLE_RIA'):
		raise Http404("Ria user does not exist.")

	# Check the group owned by the ria
	group = None;

	# Create the registration form
	form = ClientRegistrationForm(request.POST)

	# check if user exist
	user = None
	try:
		user = get_object_or_404(User, email=request.POST['email'])
	except:
		pass
	if user is not None:

		step = user.profile.registration_step
		user.first_name = request.POST['first_name']
		user.last_name  = request.POST['last_name']
		login(request, user)
		login1(request, user)
		print(step)
		return step


	if form.is_valid():
		form.instance.username = form.cleaned_data['email']
		user = form.save(commit=False) # Get user obj for info assignment
		# Validate the password
		password = form.cleaned_data.get('password1')
		try:
			validate_password(password, user)
		except ValidationError as e:
			form.add_error('password1', e)
			context = {
				'form': form,
				'ria': ria
			}
			return render(request, 'user/client_registration.html', context)
		# Assign the email information
		user.email = form.cleaned_data['email']
		# Assign the group information
		if group is None:
			group = Group.objects.get(name="All")
		# Assign the billing spec information
		billingSpec = BillingSpec.objects.get(master=True, owner=ria)
		user.appointedBillingSpec = billingSpec
		user = form.save() # Save once to have valid user id for below many-to-many relation with group
		user.groups.add(group)

		user.save()
		# Create and assign the user profile
		profile = Profile(user=user, first_name=form.cleaned_data['first_name'],
			last_name=form.cleaned_data['last_name'])
		# Assign the RIA information
		profile.ria_user = ria
		profile.client_status = Profile.CLIENT_STATUS_PROSPECT
		profile.save()
		# Create and assign the user client settings
		clientSettings = ClientSettings(client=user)
		clientSettings.save()
		# Authenticate and login the newly created user
		username = form.cleaned_data.get('email')
		request.session.save()
		user = authenticate(username=username, password=password)

		# that is when we have an actual user

		login(request, user)
		login1(request, user)

		print("the initial step is ok")


	return 0