Ejemplo n.º 1
0
def forgot_password(request):
    email = request.POST['email'].strip()
    try:
        u = User.objects.get(email = email, is_active=True)
    except:
        return json_error(INVALID_EMAIL_ERROR, 'No user at that email address.')
    pr = PasswordResetRequest()
    pr.user = u
    pr.uid = str(uuid4().hex)
    pr.save()
    p = PasswordResetRequest.objects.all()
    send_notification(type=EmailTypes.RESET_PASSWORD,
                                  user=u,
                                  entity=u,
                                  password_reset_id=pr.uid)
    return json_response({'response' : 1})
Ejemplo n.º 2
0
def forgot_password(request):
    error = None
    if request.method == 'POST':
        if 'email' in request.POST:
            try:
                u = User.objects.get(email = request.POST['email'].strip(), is_active=True)
                pr = PasswordResetRequest()
                pr.user = u
                pr.uid = str(uuid4().hex)
                pr.save()
                send_notification(type=EmailTypes.RESET_PASSWORD,
                                  user=u,
                                  entity=u,
                                  password_reset_id=pr.uid)
                return render(request, 'user/forgot_password_confirm.html', {})
            except User.DoesNotExist:
                error = "Sorry, this user account does not exist."
            except Exception:
                logging.exception("Error In Forgot Password Post")
                error = "Sorry, an unknown error has occurred."
    return render(request, 'user/forgot_password.html', {
        'error' : error
    })
Ejemplo n.º 3
0
def forgot_password(request):
    email = request.POST['email'].strip()
    try:
        u = User.objects.get(email=email, is_active=True)
    except:
        return json_error(INVALID_EMAIL_ERROR,
                          'No user at that email address.')
    pr = PasswordResetRequest()
    pr.user = u
    pr.uid = str(uuid4().hex)
    pr.save()
    p = PasswordResetRequest.objects.all()
    send_notification(type=EmailTypes.RESET_PASSWORD,
                      user=u,
                      entity=u,
                      password_reset_id=pr.uid)
    return json_response({'response': 1})
Ejemplo n.º 4
0
def forgot_password(request):
    error = None
    if request.method == 'POST':
        if 'email' in request.POST:
            try:
                u = User.objects.get(email=request.POST['email'].strip(),
                                     is_active=True)
                pr = PasswordResetRequest()
                pr.user = u
                pr.uid = str(uuid4().hex)
                pr.save()
                send_notification(type=EmailTypes.RESET_PASSWORD,
                                  user=u,
                                  entity=u,
                                  password_reset_id=pr.uid)
                return render(request, 'user/forgot_password_confirm.html', {})
            except User.DoesNotExist:
                error = "Sorry, this user account does not exist."
            except Exception:
                logging.exception("Error In Forgot Password Post")
                error = "Sorry, an unknown error has occurred."
    return render(request, 'user/forgot_password.html', {'error': error})