Esempio n. 1
0
def email(request):
    user, profile = request.user, request.user.profile
    if request.method == 'POST':
        email_new = request.POST.get('email', '').lower()
        if validate_email(email_new):
            if profile.email_authed:
                profile.email_new = email_new
                profile.save()
            else:
                user.email = email_new
                user.save()

            log_msg = 'try' if profile.email_authed else 'done'
            logger.warning(f'email.update.{log_msg}', {
                'r': request,
                'extra': [('email', email_new)],
            })
            token_issue_email_auth(user)
            request.session['result_email'] = 4
        else:
            request.session['result_email'] = 3

    result_email = request.session.pop('result_email', -1)
    return render(request, 'account/email.html', {
        'user': request.user,
        'result_email': result_email,
    })
Esempio n. 2
0
def email(request):
    email = request.GET.get('email', '')
    exclude = request.GET.get('exclude', '')
    if validate_email(email, exclude):
        return HttpResponse(status=200)
    return HttpResponse(status=400)
Esempio n. 3
0
def email(request):
    if validate_email(request.GET.get('email', '')):
        return HttpResponse(status=200)
    return HttpResponse(status=400)
Esempio n. 4
0
def email(request):
    if validate_email(request.GET.get('email', '')):
        return HttpResponse(status=200)
    return HttpResponse(status=400)
Esempio n. 5
0
    def get(self, request):
        email = request.query_params.get('email', '')
        exclude = request.query_params.get('exclude', '')

        email_valid = validate_email(email, exclude)
        return Response({}, status=status.HTTP_200_OK if email_valid else status.HTTP_400_BAD_REQUEST)