Exemplo n.º 1
0
def start_registration(request):
    from profile.profileutils import keygen, send_registration_key

    post = request.POST.copy()
    user = User(
        username=post.get('email'),
        email=post.get('email'),
        first_name=post.get('first_name'),
        last_name=post.get('last_name'),
        is_active=False)
    password = keygen(user)[:8]
    user.set_password(password)
    user.save()

    registration = Registration(user=user, key=keygen(user))
    registration.save()

    send_registration_key(request, user, password, registration)

    return True
Exemplo n.º 2
0
def lost_password(request):
    from profile.profileutils import keygen

    if request.user.is_authenticated():
        return HttpResponseRedirect('/')
    forgot = PasswordResetForm()
    if request.method == 'POST':
        post = request.POST.copy()
        forgot = PasswordResetForm(post)
        if forgot.is_valid():
            email = post.get('email')
            user = User.objects.get(email=email, username=email)
            passwd = keygen(user)[:8]
            user.set_password(passwd)
            user.save()
            send_password(user, passwd)
            return 'email_sent.html'
    return 'lost_password.html', {'remind_form': forgot}