return token after registration with django-rest-framework-simplejwt

后端 未结 3 1916
独厮守ぢ
独厮守ぢ 2021-02-04 22:46

I\'m using django-rest-framework-simplejwt and was wondering if it\'s possible to return a token after registering a user?

This post has a solution for another jwt packa

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 23:24

    I guess, you can do something like this :

    def custom_registration_view(request):
        //code to validate & register your user
        payload = jwt_payload_handler(user)
        return HttpResponse(jwt_encode_handler(payload), 201)
    

    The payload_handler, encode_handler and decode_handler you can specify in settings file.

提交回复
热议问题