From 8cd3c102f7fbab210589aed56f67eafc648ca920 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Sat, 21 Apr 2018 12:33:10 +0300 Subject: [PATCH] Fix auto create tocken --- apps/user/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/user/models.py b/apps/user/models.py index 7c3bb6ae..ebbef261 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -85,13 +85,13 @@ class User(AbstractUser): def create_auth_token(sender, instance=None, created=False, **kwargs): if ( (instance.is_active or instance.fb_id) and - instance.role in [User.AUTHOR_ROLE, User.ADMIN_ROLE] and not + instance.role in [User.AUTHOR_ROLE, User.TEACHER_ROLE, User.ADMIN_ROLE] and not hasattr(instance, 'auth_token') ): Token.objects.create(user=instance) elif ( not (instance.is_active or instance.fb_id) or - instance.role not in [User.AUTHOR_ROLE, User.ADMIN_ROLE] + instance.role not in [User.AUTHOR_ROLE, User.TEACHER_ROLE, User.ADMIN_ROLE] ) and hasattr(instance, 'auth_token'): instance.auth_token.delete()