Beispiel #1
0
 def put(self):
     data = ImmutableMultiDict(request.json)
     reset_password_form = PasswordResetForm(data, csrf_enabled=False)
     if reset_password_form.validate():
         reset_password_form.save()
         return {"status": "success", "message": "Password reset done"}
     return reset_password_form.errors
Beispiel #2
0
def password_reset(request):
    """
	Password reset view
	"""
    if request.method == "POST":
        form = PasswordResetForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/password_reset_done/')
    else:
        form = PasswordResetForm()
    return TemplateResponse(request, 'reset.html', {
        'form': form,
        'next': '/password_reset_done/'
    })
Beispiel #3
0
def password_reset(request, response_format='html'):
    "Password_reset sends the email with the new password"

    if request.POST:
        form = PasswordResetForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('password_reset_done'))
    else:
        form = PasswordResetForm()

    return render_to_response('core/password_reset_form',
                              {'form': form},
                              context_instance=RequestContext(request),
                              response_format=response_format)
Beispiel #4
0
def password_reset(request, to_email):
    from_email = '*****@*****.**'
    to_email_dict = {'email': to_email}
    token_generator = default_token_generator
    email_template_name = 'email/reset_email.html'
    subject_template_name = 'email/reset_subject.txt'
    form = PasswordResetForm(to_email_dict)
    if form.is_valid():
        opts = {
            'use_https': request.is_secure(),
            'from_email': from_email,
            'email_template_name': email_template_name,
            'subject_template_name': subject_template_name,
            'request': request}
        form.save(**opts)
Beispiel #5
0
def password_reset(request):
	"""
	Password reset view
	"""
	if request.method=="POST":
		form = PasswordResetForm(request.POST)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect('/password_reset_done/')
	else:
		form = PasswordResetForm()
	return TemplateResponse(
		request,
		'reset.html',
		{
			'form': form,
			'next': '/password_reset_done/'
		}
		)
def entity_add_user(request, entity_id):
    entity = get_object_or_404(Entity, pk=entity_id)
    if request.POST:
        form = AddUserForm(request.POST)
        if form.is_valid():
            #Lookup or create user, add to entity
            email = form.cleaned_data['email']
            form.cleaned_data['username'] = email[:30]
            del form.cleaned_data['email']
            user, created = User.objects.get_or_create(email=email, defaults=form.cleaned_data)
            if created:
                reset_form = PasswordResetForm({'email':user.email})
                reset_form.is_valid()
                reset_form.save(email_template_name="registration/new_account.html", subject=_("Account created on %s"))
            assign('change_entity', user, entity)
            return HttpResponseRedirect(reverse('show_user',args=[user.pk]))
    else:
        form = AddUserForm()
    return render_to_response('scorecard_processor/entity/add_user.html', {'object':entity,'form':form}, RequestContext(request))