'''
Authentication
'''
# pylint: disable=W0212
from oauth2_provider.contrib.rest_framework.authentication import \
    OAuth2Authentication


class HotelAppOAuth2Authentication(OAuth2Authentication):
    '''
    Hotel App OAuth Authentication
    '''

    def authenticate(self, request):
        """
        Returns two-tuple of (user, token) if authentication succeeds,
        or None otherwise.
        """
        user_auth = super(HotelAppOAuth2Authentication,
                          self).authenticate(request)
        if user_auth:
            request.user = user_auth[0]
        return user_auth
