# Path: apps/teams/models.py
# class Team(AbstractBaseUser, PermissionsMixin):
#     name = models.CharField(max_length=60, help_text=_("team name"), blank=False, null=False, unique=True, db_index=True)
#     is_staff = models.BooleanField(help_text=_('staff status'), blank=False, null=False, default=False, db_index=True)
#     is_active = models.BooleanField(help_text=_('User can log in'), blank=False, null=False, default=True, db_index=True)
#     token = models.CharField(max_length=64, unique=True, blank=False, null=True, db_index=True)
# 
#     USERNAME_FIELD = 'name'
# 
#     objects = TeamManager()
# 
#     @property
#     def get_full_name(self):
#         return self.name
# 
#     @property
#     def get_short_name(self):
#         return self.name
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
#         return reverse('teams.views.show', args=[self.name])


from .models import Team
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals, absolute_import


__author__ = 'Last G'


class TokenAuthBackend(object):
    def authenticate(self, token=None):
        if token:
            return Team.objects.filter(token=token).first()
        return None

    def get_user(self, user_id, *args, **kwargs):
        try:

# Path: apps/teams/models.py
# class Team(AbstractBaseUser, PermissionsMixin):
#     name = models.CharField(max_length=60, help_text=_("team name"), blank=False, null=False, unique=True, db_index=True)
#     is_staff = models.BooleanField(help_text=_('staff status'), blank=False, null=False, default=False, db_index=True)
#     is_active = models.BooleanField(help_text=_('User can log in'), blank=False, null=False, default=True, db_index=True)
#     token = models.CharField(max_length=64, unique=True, blank=False, null=True, db_index=True)
# 
#     USERNAME_FIELD = 'name'
# 
#     objects = TeamManager()
# 
#     @property
#     def get_full_name(self):
#         return self.name
# 
#     @property
#     def get_short_name(self):
#         return self.name
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
#         return reverse('teams.views.show', args=[self.name])


# Path: apps/teams/auth.py
from .models import Team

# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals, absolute_import


__author__ = 'Last G'


class TokenAuthBackend(object):
    def authenticate(self, token=None):
        if token:
            return Team.objects.filter(token=token).first()
        return None

    def get_user(self, user_id, *args, **kwargs):
        try:

            return Team.objects.get(pk=user_id)