N
N
NikClik2018-12-18 16:22:07
Django
NikClik, 2018-12-18 16:22:07

How to send user data in signal after user login?

Since my front and back exist separately from each other, I have a custom login function, here it is:

@csrf_exempt
def custom_login(request):
    if request.method == 'POST':
        data = json.loads(request.body)
        user = authenticate(request, username=data['login'], password=data['password'])
        request.user = user
        if user is not None:
            login(request, user)
            return HttpResponse(User.get_full_name(user))
        else:
            return HttpResponse('None')

I also have signals in my program, the bottom line is that I somehow need to get the data of the logged in user, after he logs in, in signals, how to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Shatalov, 2018-12-18
@netpastor

Create your signal
https://docs.djangoproject.com/en/2.1/topics/signa...

T
tema_sun, 2018-12-18
@tema_sun

Why not use the built in user_logged_in signal?
https://docs.djangoproject.com/en/dev/ref/contrib/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question