Skip to content

Social REST auth with REST_SESSION_LOGIN = True #64

Open
@vosi

Description

@vosi

SocialLogin view class should have its own login method to assign some backend to user object, because dango.contrib.auth.login requires backend property, that usually is assigned by authenticate method

currently i've just made a dirty fix like this

class SocialLogin(OldSocialLogin):
    def login(self):
        # import ipdb; ipdb.set_trace()
        self.user = self.serializer.validated_data['user']
        self.token, created = self.token_model.objects.get_or_create(
            user=self.user)
        if getattr(settings, 'REST_SESSION_LOGIN', True):
            if not hasattr(self.user, 'backend'):
                self.user.backend = 'django.contrib.auth.backends.ModelBackend'
            login(self.request, self.user)

but im sure it is not the most beautiful solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions