Skip to content

Instantly share code, notes, and snippets.

@ydnax
Created March 2, 2012 16:09
Show Gist options
  • Save ydnax/1959366 to your computer and use it in GitHub Desktop.
Save ydnax/1959366 to your computer and use it in GitHub Desktop.
from django.contrib.auth import login,logout,authenticate
#viel code dazwischen
def login(request, loginid):
try:
user=UserProfile.objects.filter(mailcode=loginid)[0].user
newpass=id_generator(50)
user.set_password(newpass)
user.save()
authenticated=authenticate(username=user.username, password=newpass)
login(request, authenticated)
return HttpResponseRedirect(reverse('store'))
except IndexError:
return "blub"
return render_to_response('template_error.html', {
'title' : 'Error',
'text' : 'Dieser Loginlink scheint ungueltig zu sein.'},
context_instance=RequestContext(request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment