Re: Credentials fail from custom Auth backend

2021-07-05 Thread David Crandell
ontact2_city_st = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emp_note = models.TextField(default=None, null=True, blank=True)
> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_image = models.ImageField(upload_to='profile-pics/', 
> default='profile-pics/default.png', null=True, blank=True)
> last_login = models.DateTimeField(default=None, null=True)
> is_staff = models.BooleanField(default=True, blank=True)
> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
> is_superuser = models.BooleanField(default=False, blank=True)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = []
>
> def get_full_name(self):
> return f'{self.first_name} {self.last_name}'
>
> def get_email(self):
> return self.email
>
> def __str__(self):
> return self.email
>
> @property
> def is_staff(self):
> return self.staff
>
> @property
> def is_admin(self):
> return self.admin
>
> def save(self, *args, **kwargs):
> super(Emp, self).save(*args, **kwargs)
>
> img = Image.open(self.emp_image.path)
>
> if img.height > 300 or img.width > 300:
> output_size = (300, 300)
> img.thumbnail(output_size)
> img.save(self.emp_image.image)
>
> self.last_login = timezone.utc
>
> def get_absolute_url(self):
> return reverse('employees:emp-detail', args=[self.id])
>
> objects = UserManager()
> On Sunday, July 4, 2021 at 9:14:21 PM UTC-5 ANi wrote:
>
>> What does the error message say? 
>> guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:
>>
>>> Hello, I am using a custom auth backend and everything displays 
>>> properly, except I cannot login with the credentials in my model. I have 
>>> spent 5 hours on this and cannot figure it out. Please help.
>>>
>>> views.py
>>>
>>> class MyLogin(LoginView):
>>> template_name = 'employees/login.html'
>>> form_class = LoginForm
>>>
>>>
>>> def form_valid(self, form):
>>> user = form.get_user()
>>> employee = Emp.objects.get(email=user)
>>> if employee.is_active:
>>> EmpBackend.authenticate(self.request, username=user, 
>>> password=form.password)
>>>
>>> return HttpResponseRedirect(self.get_success_url())
>>>
>>> backends.py
>>>
>>> from django.contrib.auth.backends import ModelBackend
>>> from .models import Emp
>>>
>>>
>>> class EmpBackend(ModelBackend):
>>> def authenticate(self, request, username=None, password=None, **kwargs):
>>> try:
>>> user = Emp.objects.get(email=username)
>>> if user.check_password(password):
>>> return user
>>> except Emp.DoesNotExist:
>>> return None
>>>
>>> return None
>>>
>>> def get_user(self, user_id):
>>> try:
>>> return Emp.objects.get(pk=user_id)
>>> except Emp.DoesNotExist:
>>> return None
>>>
>>> models.py
>>>
>>> class Emp(AbstractBaseUser):
>>> first_name = models.CharField(max_length=100, default=None)
>>> last_name = models.CharField(max_length=100, default=None)
>>> email = models.EmailField(max_length=255, default=None, unique=True)
>>> username = models.CharField(max_length=100, default=None, null=True)
>>> phone = models.CharField(max_length=20, default=None, null=True, 
>>> blank=True)
>>> password = models.CharField(max_length=100)
>>> address1 = models.CharField(max_length=100, default=None, null=True, 
>>> blank=True)
>>> address2 = models.CharField(max_length=100, default=None, null=True, 
>>> blank=True)
>>> city = models.CharField(max_length=100, default=None, null=True, 
>>> blank=True)
>>> state = models.CharField(max_length=100, default=None, null=True, 
>>> blank=True)
>>> zip = models.CharField(max_length=10, default=None, null=True, 
>>> blank=True)
>>> position = models.CharField(max_length=50, default=None)
>>> date_hired = models.DateTimeField(auto_now_add=True)
>>> date_updated = models.DateTimeField(auto_now_add=True)
>>> date_terminated = models.DateTimeField(default=None, null=True, 
>>> blank=True)
>>> is_active = models.BooleanField(default=True)
>>> status = models.SmallIntegerField(default=0)
>>> emp_is_salary = models.BooleanField(default=False)
>>> emp_pto_rate = models.

Re: Credentials fail from custom Auth backend

2021-07-05 Thread David Crandell
er()


On Sunday, July 4, 2021 at 9:14:21 PM UTC-5 ANi wrote:

> What does the error message say? 
> guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:
>
>> Hello, I am using a custom auth backend and everything displays properly, 
>> except I cannot login with the credentials in my model. I have spent 5 
>> hours on this and cannot figure it out. Please help.
>>
>> views.py
>>
>> class MyLogin(LoginView):
>> template_name = 'employees/login.html'
>> form_class = LoginForm
>>
>>
>> def form_valid(self, form):
>> user = form.get_user()
>> employee = Emp.objects.get(email=user)
>> if employee.is_active:
>> EmpBackend.authenticate(self.request, username=user, 
>> password=form.password)
>>
>> return HttpResponseRedirect(self.get_success_url())
>>
>> backends.py
>>
>> from django.contrib.auth.backends import ModelBackend
>> from .models import Emp
>>
>>
>> class EmpBackend(ModelBackend):
>> def authenticate(self, request, username=None, password=None, **kwargs):
>> try:
>> user = Emp.objects.get(email=username)
>> if user.check_password(password):
>> return user
>> except Emp.DoesNotExist:
>> return None
>>
>> return None
>>
>> def get_user(self, user_id):
>> try:
>> return Emp.objects.get(pk=user_id)
>> except Emp.DoesNotExist:
>> return None
>>
>> models.py
>>
>> class Emp(AbstractBaseUser):
>> first_name = models.CharField(max_length=100, default=None)
>> last_name = models.CharField(max_length=100, default=None)
>> email = models.EmailField(max_length=255, default=None, unique=True)
>> username = models.CharField(max_length=100, default=None, null=True)
>> phone = models.CharField(max_length=20, default=None, null=True, 
>> blank=True)
>> password = models.CharField(max_length=100)
>> address1 = models.CharField(max_length=100, default=None, null=True, 
>> blank=True)
>> address2 = models.CharField(max_length=100, default=None, null=True, 
>> blank=True)
>> city = models.CharField(max_length=100, default=None, null=True, 
>> blank=True)
>> state = models.CharField(max_length=100, default=None, null=True, 
>> blank=True)
>> zip = models.CharField(max_length=10, default=None, null=True, blank=True)
>> position = models.CharField(max_length=50, default=None)
>> date_hired = models.DateTimeField(auto_now_add=True)
>> date_updated = models.DateTimeField(auto_now_add=True)
>> date_terminated = models.DateTimeField(default=None, null=True, 
>> blank=True)
>> is_active = models.BooleanField(default=True)
>> status = models.SmallIntegerField(default=0)
>> emp_is_salary = models.BooleanField(default=False)
>> emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4, 
>> default=0.0)
>> emp_user_level = models.SmallIntegerField(default=1)
>> emerg_contact1 = models.CharField(max_length=100, default=None, 
>> null=True, blank=True)
>> emerg_contact1_phone = models.CharField(max_length=20, default=None, 
>> null=True, blank=True)
>> emerg_contact1_address = models.CharField(max_length=200, default=None, 
>> null=True, blank=True)
>> emerg_contact1_city_st = models.CharField(max_length=200, default=None, 
>> null=True, blank=True)
>> emerg_contact2 = models.CharField(max_length=100, default=None, 
>> null=True, blank=True)
>> emerg_contact2_phone = models.CharField(max_length=20, default=None, 
>> null=True, blank=True)
>> emerg_contact2_address = models.CharField(max_length=200, default=None, 
>> null=True, blank=True)
>> emerg_contact2_city_st = models.CharField(max_length=200, default=None, 
>> null=True, blank=True)
>> emp_note = models.TextField(default=None, null=True, blank=True)
>> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4, 
>> default=0.0)
>> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4, 
>> default=0.0)
>> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4, 
>> default=0.0)
>> emp_image = models.ImageField(upload_to='profile-pics/', 
>> default='profile-pics/default.png', null=True, blank=True)
>> last_login = models.DateTimeField(default=None, null=True)
>> is_staff = models.BooleanField(default=True, blank=True)
>> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
>> is_superuser = models.BooleanField(default=False, blank=True)
>>
>> USERNAME_FIELD = 'email'
>> REQUIRED_FIELDS = []
>>
>> def get_full_name(self):
>> return f'{self.first_name} {self.last_name}'
>>

Re: Credentials fail from custom Auth backend

2021-07-04 Thread David Crandell
There is no error. It just says invalid login. I get the login template and
it rejects my credentials.

David L. Crandell
469-585-5009
g uitard...@outlook.com
guitardave8...@gmail.com
da...@onholdwizard.com



On Sun, Jul 4, 2021 at 9:15 PM ANi  wrote:

> What does the error message say?
> guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:
>
>> Hello, I am using a custom auth backend and everything displays properly,
>> except I cannot login with the credentials in my model. I have spent 5
>> hours on this and cannot figure it out. Please help.
>>
>> views.py
>>
>> class MyLogin(LoginView):
>> template_name = 'employees/login.html'
>> form_class = LoginForm
>>
>>
>> def form_valid(self, form):
>> user = form.get_user()
>> employee = Emp.objects.get(email=user)
>> if employee.is_active:
>> EmpBackend.authenticate(self.request, username=user,
>> password=form.password)
>>
>> return HttpResponseRedirect(self.get_success_url())
>>
>> backends.py
>>
>> from django.contrib.auth.backends import ModelBackend
>> from .models import Emp
>>
>>
>> class EmpBackend(ModelBackend):
>> def authenticate(self, request, username=None, password=None, **kwargs):
>> try:
>> user = Emp.objects.get(email=username)
>> if user.check_password(password):
>> return user
>> except Emp.DoesNotExist:
>> return None
>>
>> return None
>>
>> def get_user(self, user_id):
>> try:
>> return Emp.objects.get(pk=user_id)
>> except Emp.DoesNotExist:
>> return None
>>
>> models.py
>>
>> class Emp(AbstractBaseUser):
>> first_name = models.CharField(max_length=100, default=None)
>> last_name = models.CharField(max_length=100, default=None)
>> email = models.EmailField(max_length=255, default=None, unique=True)
>> username = models.CharField(max_length=100, default=None, null=True)
>> phone = models.CharField(max_length=20, default=None, null=True,
>> blank=True)
>> password = models.CharField(max_length=100)
>> address1 = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> address2 = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> city = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> state = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> zip = models.CharField(max_length=10, default=None, null=True, blank=True)
>> position = models.CharField(max_length=50, default=None)
>> date_hired = models.DateTimeField(auto_now_add=True)
>> date_updated = models.DateTimeField(auto_now_add=True)
>> date_terminated = models.DateTimeField(default=None, null=True,
>> blank=True)
>> is_active = models.BooleanField(default=True)
>> status = models.SmallIntegerField(default=0)
>> emp_is_salary = models.BooleanField(default=False)
>> emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_user_level = models.SmallIntegerField(default=1)
>> emerg_contact1 = models.CharField(max_length=100, default=None,
>> null=True, blank=True)
>> emerg_contact1_phone = models.CharField(max_length=20, default=None,
>> null=True, blank=True)
>> emerg_contact1_address = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact1_city_st = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact2 = models.CharField(max_length=100, default=None,
>> null=True, blank=True)
>> emerg_contact2_phone = models.CharField(max_length=20, default=None,
>> null=True, blank=True)
>> emerg_contact2_address = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact2_city_st = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emp_note = models.TextField(default=None, null=True, blank=True)
>> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_image = models.ImageField(upload_to='profile-pics/',
>> default='profile-pics/default.png', null=True, blank=True)
>> last_login = models.DateTimeField(default=None, null=True)
>> is_staff = models.BooleanField(default=True, blank=True)
>> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
>> is_superuser = models.BooleanField(default=False, blank=True)
>>

Re: Credentials fail from custom Auth backend

2021-07-04 Thread ANi
What does the error message say? 
guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:

> Hello, I am using a custom auth backend and everything displays properly, 
> except I cannot login with the credentials in my model. I have spent 5 
> hours on this and cannot figure it out. Please help.
>
> views.py
>
> class MyLogin(LoginView):
> template_name = 'employees/login.html'
> form_class = LoginForm
>
>
> def form_valid(self, form):
> user = form.get_user()
> employee = Emp.objects.get(email=user)
> if employee.is_active:
> EmpBackend.authenticate(self.request, username=user, 
> password=form.password)
>
> return HttpResponseRedirect(self.get_success_url())
>
> backends.py
>
> from django.contrib.auth.backends import ModelBackend
> from .models import Emp
>
>
> class EmpBackend(ModelBackend):
> def authenticate(self, request, username=None, password=None, **kwargs):
> try:
> user = Emp.objects.get(email=username)
> if user.check_password(password):
> return user
> except Emp.DoesNotExist:
> return None
>
> return None
>
> def get_user(self, user_id):
> try:
> return Emp.objects.get(pk=user_id)
> except Emp.DoesNotExist:
> return None
>
> models.py
>
> class Emp(AbstractBaseUser):
> first_name = models.CharField(max_length=100, default=None)
> last_name = models.CharField(max_length=100, default=None)
> email = models.EmailField(max_length=255, default=None, unique=True)
> username = models.CharField(max_length=100, default=None, null=True)
> phone = models.CharField(max_length=20, default=None, null=True, 
> blank=True)
> password = models.CharField(max_length=100)
> address1 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> address2 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> city = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> state = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> zip = models.CharField(max_length=10, default=None, null=True, blank=True)
> position = models.CharField(max_length=50, default=None)
> date_hired = models.DateTimeField(auto_now_add=True)
> date_updated = models.DateTimeField(auto_now_add=True)
> date_terminated = models.DateTimeField(default=None, null=True, blank=True)
> is_active = models.BooleanField(default=True)
> status = models.SmallIntegerField(default=0)
> emp_is_salary = models.BooleanField(default=False)
> emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_user_level = models.SmallIntegerField(default=1)
> emerg_contact1 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> emerg_contact1_phone = models.CharField(max_length=20, default=None, 
> null=True, blank=True)
> emerg_contact1_address = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact1_city_st = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact2 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> emerg_contact2_phone = models.CharField(max_length=20, default=None, 
> null=True, blank=True)
> emerg_contact2_address = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact2_city_st = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emp_note = models.TextField(default=None, null=True, blank=True)
> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_image = models.ImageField(upload_to='profile-pics/', 
> default='profile-pics/default.png', null=True, blank=True)
> last_login = models.DateTimeField(default=None, null=True)
> is_staff = models.BooleanField(default=True, blank=True)
> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
> is_superuser = models.BooleanField(default=False, blank=True)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = []
>
> def get_full_name(self):
> return f'{self.first_name} {self.last_name}'
>
> def get_email(self):
> return self.email
>
> def __str__(self):
> return self.email
>
> def has_perm(self, perm, obj=None):
> return True
>
> def has_module_perms(self, app_label):
> return True
>
> @property
> def is_staff(self):
> return self.staff
>
> @property
> def is_admin(self):
> return self.admin
>
> def save(self, *args, **kwargs):
> super(Emp, self).save(*args, **kwargs)
>
> img = Image.open(self.emp_image.path)
>
> if

Credentials fail from custom Auth backend

2021-07-03 Thread David Crandell
Hello, I am using a custom auth backend and everything displays properly, 
except I cannot login with the credentials in my model. I have spent 5 
hours on this and cannot figure it out. Please help.

views.py

class MyLogin(LoginView):
template_name = 'employees/login.html'
form_class = LoginForm


def form_valid(self, form):
user = form.get_user()
employee = Emp.objects.get(email=user)
if employee.is_active:
EmpBackend.authenticate(self.request, username=user, password=form.password)

return HttpResponseRedirect(self.get_success_url())

backends.py

from django.contrib.auth.backends import ModelBackend
from .models import Emp


class EmpBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
try:
user = Emp.objects.get(email=username)
if user.check_password(password):
return user
except Emp.DoesNotExist:
return None

return None

def get_user(self, user_id):
try:
return Emp.objects.get(pk=user_id)
except Emp.DoesNotExist:
return None

models.py

class Emp(AbstractBaseUser):
first_name = models.CharField(max_length=100, default=None)
last_name = models.CharField(max_length=100, default=None)
email = models.EmailField(max_length=255, default=None, unique=True)
username = models.CharField(max_length=100, default=None, null=True)
phone = models.CharField(max_length=20, default=None, null=True, blank=True)
password = models.CharField(max_length=100)
address1 = models.CharField(max_length=100, default=None, null=True, 
blank=True)
address2 = models.CharField(max_length=100, default=None, null=True, 
blank=True)
city = models.CharField(max_length=100, default=None, null=True, blank=True)
state = models.CharField(max_length=100, default=None, null=True, 
blank=True)
zip = models.CharField(max_length=10, default=None, null=True, blank=True)
position = models.CharField(max_length=50, default=None)
date_hired = models.DateTimeField(auto_now_add=True)
date_updated = models.DateTimeField(auto_now_add=True)
date_terminated = models.DateTimeField(default=None, null=True, blank=True)
is_active = models.BooleanField(default=True)
status = models.SmallIntegerField(default=0)
emp_is_salary = models.BooleanField(default=False)
emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4, 
default=0.0)
emp_user_level = models.SmallIntegerField(default=1)
emerg_contact1 = models.CharField(max_length=100, default=None, null=True, 
blank=True)
emerg_contact1_phone = models.CharField(max_length=20, default=None, 
null=True, blank=True)
emerg_contact1_address = models.CharField(max_length=200, default=None, 
null=True, blank=True)
emerg_contact1_city_st = models.CharField(max_length=200, default=None, 
null=True, blank=True)
emerg_contact2 = models.CharField(max_length=100, default=None, null=True, 
blank=True)
emerg_contact2_phone = models.CharField(max_length=20, default=None, 
null=True, blank=True)
emerg_contact2_address = models.CharField(max_length=200, default=None, 
null=True, blank=True)
emerg_contact2_city_st = models.CharField(max_length=200, default=None, 
null=True, blank=True)
emp_note = models.TextField(default=None, null=True, blank=True)
emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4, 
default=0.0)
emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4, 
default=0.0)
emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4, 
default=0.0)
emp_image = models.ImageField(upload_to='profile-pics/', 
default='profile-pics/default.png', null=True, blank=True)
last_login = models.DateTimeField(default=None, null=True)
is_staff = models.BooleanField(default=True, blank=True)
date_joined = models.DateTimeField(auto_now_add=True, blank=True)
is_superuser = models.BooleanField(default=False, blank=True)

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []

def get_full_name(self):
return f'{self.first_name} {self.last_name}'

def get_email(self):
return self.email

def __str__(self):
return self.email

def has_perm(self, perm, obj=None):
return True

def has_module_perms(self, app_label):
return True

@property
def is_staff(self):
return self.staff

@property
def is_admin(self):
return self.admin

def save(self, *args, **kwargs):
super(Emp, self).save(*args, **kwargs)

img = Image.open(self.emp_image.path)

if img.height > 300 or img.width > 300:
output_size = (300, 300)
img.thumbnail(output_size)
img.save(self.emp_image.image)

self.last_login = timezone.utc

def get_absolute_url(self):
return reverse('employees:emp-detail', args=[self.id])

objects = UserManager()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57d4c910-c96b-486c-b5ec-461f38568de8n%40googlegroups.com.


Re: CUSTOM AUTH WITH CELERY WORKER FOR SENDING EMAIL

2021-06-18 Thread Kuassi Israel
But if you have already implemented a smoother and lighter process then you
can tell me about it or give me some ideas.

On Fri, Jun 18, 2021 at 12:20 PM Kuassi Israel 
wrote:

> I did a custom authentication with DJANGO and in the confirmation of MAIL
> and phone number I send corn and sms. It is a platform that will be used by
> many customers. So I installed CELERY to manage the QUEUE of sending of sms
> and mail. But I could not do the right configuration so as to call the
> tasks in the background to deliver emails and sms. But there I already
> solved the problem by creating tasks specified for just sending emails and
> just sending SMS in my TASKS.PY and I configured specialized QUEUES for
> MAILS and SMS at the level of my CELERY.PY and with DJANGO CELERY RESULTS I
> use the DANGO-DB STOKAGE ENGINE.
>
> On Wed, Jun 16, 2021 at 7:06 PM Nikeet NA  wrote:
>
>> Can you describe in detail , sending mails is possible through celery but
>> i am un clear about auth part.
>>
>> On Wednesday, 16 June 2021 at 22:31:41 UTC+5:30 kuassi...@paydunya.com
>> wrote:
>>
>>> Hello Community. I would like to have recommendations on how to
>>> implement a custom authentication with the use of CELERY for sending mails
>>> which will be QUEUE and managed by a workers that I will start on my server
>>> with the BROKER REDIS.
>>>
>>> Please if anyone have suggestions for me or any articles for that i'm
>>> glad to receive them.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/e5961172-716a-4a6b-a21f-54502a20a045n%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Israël KUASSI
>
> Web Software developer
>
> Technique | PayDunya
> +221338659045 | +221771022089
> kuassi.isr...@paydunya.com
> www.paydunya.com
> Immeuble Forum Center-VDN, Ouest Foire en face CICES, DAKAR
> [image: facebook] 
> [image: twitter] 
> [image: linkedin] 
> Create Your Own Free Signature
>


-- 
Israël KUASSI

Web Software developer

Technique | PayDunya
+221338659045 | +221771022089
kuassi.isr...@paydunya.com
www.paydunya.com
Immeuble Forum Center-VDN, Ouest Foire en face CICES, DAKAR
[image: facebook] 
[image: twitter] 
[image: linkedin] 
Create Your Own Free Signature

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGMKQD6vPO2-UU9xm7gN5Y2YNDcgwOMVn-6H%2Bz66Xa8zMpSa8w%40mail.gmail.com.


Re: CUSTOM AUTH WITH CELERY WORKER FOR SENDING EMAIL

2021-06-18 Thread Kuassi Israel
I did a custom authentication with DJANGO and in the confirmation of MAIL
and phone number I send corn and sms. It is a platform that will be used by
many customers. So I installed CELERY to manage the QUEUE of sending of sms
and mail. But I could not do the right configuration so as to call the
tasks in the background to deliver emails and sms. But there I already
solved the problem by creating tasks specified for just sending emails and
just sending SMS in my TASKS.PY and I configured specialized QUEUES for
MAILS and SMS at the level of my CELERY.PY and with DJANGO CELERY RESULTS I
use the DANGO-DB STOKAGE ENGINE.

On Wed, Jun 16, 2021 at 7:06 PM Nikeet NA  wrote:

> Can you describe in detail , sending mails is possible through celery but
> i am un clear about auth part.
>
> On Wednesday, 16 June 2021 at 22:31:41 UTC+5:30 kuassi...@paydunya.com
> wrote:
>
>> Hello Community. I would like to have recommendations on how to implement
>> a custom authentication with the use of CELERY for sending mails which will
>> be QUEUE and managed by a workers that I will start on my server with the
>> BROKER REDIS.
>>
>> Please if anyone have suggestions for me or any articles for that i'm
>> glad to receive them.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e5961172-716a-4a6b-a21f-54502a20a045n%40googlegroups.com
> 
> .
>


-- 
Israël KUASSI

Web Software developer

Technique | PayDunya
+221338659045 | +221771022089
kuassi.isr...@paydunya.com
www.paydunya.com
Immeuble Forum Center-VDN, Ouest Foire en face CICES, DAKAR
[image: facebook] 
[image: twitter] 
[image: linkedin] 
Create Your Own Free Signature

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGMKQD5116f1qsFT-45sX2Jg4zYe5szBnsy3q54X6tjGZHvsPA%40mail.gmail.com.


Re: CUSTOM AUTH WITH CELERY WORKER FOR SENDING EMAIL

2021-06-16 Thread Nikeet NA
Can you describe in detail , sending mails is possible through celery but i 
am un clear about auth part.

On Wednesday, 16 June 2021 at 22:31:41 UTC+5:30 kuassi...@paydunya.com 
wrote:

> Hello Community. I would like to have recommendations on how to implement 
> a custom authentication with the use of CELERY for sending mails which will 
> be QUEUE and managed by a workers that I will start on my server with the 
> BROKER REDIS.
>
> Please if anyone have suggestions for me or any articles for that i'm glad 
> to receive them.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e5961172-716a-4a6b-a21f-54502a20a045n%40googlegroups.com.


CUSTOM AUTH WITH CELERY WORKER FOR SENDING EMAIL

2021-06-16 Thread Kuassi Israel
Hello Community. I would like to have recommendations on how to implement a 
custom authentication with the use of CELERY for sending mails which will 
be QUEUE and managed by a workers that I will start on my server with the 
BROKER REDIS.

Please if anyone have suggestions for me or any articles for that i'm glad 
to receive them.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b1e3a75-a347-417b-aa78-e346aac10ce9n%40googlegroups.com.


Re: Writing tests for a custom auth

2014-10-11 Thread Russell Keith-Magee
Hi Valery,

You probably don't need to reproduce everything that is labeled
@skipIfCustomUser - those tests are the "core" tests to make sure the basic
auth mechanisms work as expected. The remaining tests are the ones that
exist to make sure that a couple of key patterns in custom Users work as
expected. If you're writing a test suite for your own user model, you don't
need to re-validated that the core logic works as expected - you just need
to validate that your extensions play well with the core.

Yours,
Russ Magee %-)

On Sat, Oct 11, 2014 at 4:13 PM, Valery Melou <valeryme...@gmail.com> wrote:

> Thanks for your answer Russell.
> I've been browsing the django.contrib.auth.test module and I was wondering
> if I should just rewrite all tests marked @sikpIfCustomUser. If so, there
> is a lot of work to do. Anyway I will start by checking those marked
> @override_settings(AUTH_USER_MODEL='auth.ExtensionUser') as you suggested.
> Thanks again.
>
> Le samedi 11 octobre 2014 00:49:51 UTC+1, Russell Keith-Magee a écrit :
>>
>> Hi Valery,
>>
>> We don't currently ship an integration test to validate your custom User
>> model, for two reasons:
>>
>>  1) The requirements for a User model depends on what features you're
>> using - the core requirements are listed in the docs, but depending on
>> exactly what you're doing with the User model, there might be other
>> integration requirements.
>>
>>  2) We haven't got a good way to distribute a test suite for a model that
>> we haven't defined.
>>
>> That said, the baked in test suite in django.contrib.auth does test a
>> number of tests to ensure that custom User models work; if you're looking
>> for a starting point, that suite might be a good starting point. Any test
>> that isn't marked @skipIfCustomUser needs to pass regardless of the user
>> model. Tests labelled 
>> @override_settings(AUTH_USER_MODEL='auth.ExtensionUser')
>> are tests for specific user models, which will give you an idea of the sort
>> of tests you might need to add for your own model.
>>
>> I hope that helps. If, as a result of doing this, you end up with a
>> template for a good set of integration tests for a custom model, this would
>> be a good contribution back to the community - a "template" project for a
>> custom User model app that others can fork and modify as required would be
>> one way for Django to distribute an integration test suite.
>>
>> Yours,
>> Russ Magee %-)
>>
>> On Fri, Oct 10, 2014 at 4:24 PM, Valery Melou <valer...@gmail.com> wrote:
>>
>>> Hi everybody.
>>> I'm creating a custom auth user model to remove 'first_name' and
>>> 'last_name' attributes from the default one and to make the 'email' field
>>> required and unique. I would like to know which tests I'm supposed to write
>>> to make sure that my model support each feature of the default one.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f0eccad9-6d6f-4b8c-ada5-ae744c0f6692%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f0eccad9-6d6f-4b8c-ada5-ae744c0f6692%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq849vSqTwEhBphPgZed_7vzg2%3D%3DS%2B9BfYWdaWR9F_b9%2BdWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing tests for a custom auth

2014-10-11 Thread Valery Melou
Thanks for your answer Russell.
I've been browsing the django.contrib.auth.test module and I was wondering 
if I should just rewrite all tests marked @sikpIfCustomUser. If so, there 
is a lot of work to do. Anyway I will start by checking those marked 
@override_settings(AUTH_USER_MODEL='auth.ExtensionUser') as you suggested.
Thanks again.

Le samedi 11 octobre 2014 00:49:51 UTC+1, Russell Keith-Magee a écrit :
>
> Hi Valery,
>
> We don't currently ship an integration test to validate your custom User 
> model, for two reasons:
>
>  1) The requirements for a User model depends on what features you're 
> using - the core requirements are listed in the docs, but depending on 
> exactly what you're doing with the User model, there might be other 
> integration requirements.
>
>  2) We haven't got a good way to distribute a test suite for a model that 
> we haven't defined.
>
> That said, the baked in test suite in django.contrib.auth does test a 
> number of tests to ensure that custom User models work; if you're looking 
> for a starting point, that suite might be a good starting point. Any test 
> that isn't marked @skipIfCustomUser needs to pass regardless of the user 
> model. Tests labelled 
> @override_settings(AUTH_USER_MODEL='auth.ExtensionUser') are tests for 
> specific user models, which will give you an idea of the sort of tests you 
> might need to add for your own model.
>
> I hope that helps. If, as a result of doing this, you end up with a 
> template for a good set of integration tests for a custom model, this would 
> be a good contribution back to the community - a "template" project for a 
> custom User model app that others can fork and modify as required would be 
> one way for Django to distribute an integration test suite.
>
> Yours,
> Russ Magee %-)
>
> On Fri, Oct 10, 2014 at 4:24 PM, Valery Melou <valer...@gmail.com 
> > wrote:
>
>> Hi everybody.
>> I'm creating a custom auth user model to remove 'first_name' and 
>> 'last_name' attributes from the default one and to make the 'email' field 
>> required and unique. I would like to know which tests I'm supposed to write 
>> to make sure that my model support each feature of the default one.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f0eccad9-6d6f-4b8c-ada5-ae744c0f6692%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Writing tests for a custom auth

2014-10-10 Thread Russell Keith-Magee
Hi Valery,

We don't currently ship an integration test to validate your custom User
model, for two reasons:

 1) The requirements for a User model depends on what features you're using
- the core requirements are listed in the docs, but depending on exactly
what you're doing with the User model, there might be other integration
requirements.

 2) We haven't got a good way to distribute a test suite for a model that
we haven't defined.

That said, the baked in test suite in django.contrib.auth does test a
number of tests to ensure that custom User models work; if you're looking
for a starting point, that suite might be a good starting point. Any test
that isn't marked @skipIfCustomUser needs to pass regardless of the user
model. Tests labelled
@override_settings(AUTH_USER_MODEL='auth.ExtensionUser') are tests for
specific user models, which will give you an idea of the sort of tests you
might need to add for your own model.

I hope that helps. If, as a result of doing this, you end up with a
template for a good set of integration tests for a custom model, this would
be a good contribution back to the community - a "template" project for a
custom User model app that others can fork and modify as required would be
one way for Django to distribute an integration test suite.

Yours,
Russ Magee %-)

On Fri, Oct 10, 2014 at 4:24 PM, Valery Melou <valeryme...@gmail.com> wrote:

> Hi everybody.
> I'm creating a custom auth user model to remove 'first_name' and
> 'last_name' attributes from the default one and to make the 'email' field
> required and unique. I would like to know which tests I'm supposed to write
> to make sure that my model support each feature of the default one.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq849dDLq%3DitC7HujBqCT_8O-3VgmA_z7orpH-snZyguAxRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Writing tests for a custom auth

2014-10-10 Thread Valery Melou
Hi everybody.
I'm creating a custom auth user model to remove 'first_name' and 
'last_name' attributes from the default one and to make the 'email' field 
required and unique. I would like to know which tests I'm supposed to write 
to make sure that my model support each feature of the default one.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91e947b3-b3d4-4cdc-b7d0-b3426eeea668%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can not add a group to a custom auth user

2014-09-01 Thread Ikaros andi
super(Merchant, self).save(force_insert=True) 

solved the problem!


On Monday, September 1, 2014 2:15:22 PM UTC+8, Ikaros andi wrote:
>
> I debug into save method and find:
>
> ValueError: "" needs to have a value for field "user" 
> before this many-to-many relationship can be used.
>
> Merchant have already been super saved. I can figure it out
>
>
>
>
> On Wednesday, August 27, 2014 10:08:15 PM UTC+8, Collin Anderson wrote:
>>
>> i assume "groups" is an editable field in the admin.
>>
>> after the admin calls merchant.save(), it then clears out and re-assigns 
>> the value of groups based on the data in the input field.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f746f39e-1933-4c64-bc10-f1516da803d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can not add a group to a custom auth user

2014-09-01 Thread Ikaros andi
I debug into save method and find:

ValueError: "" needs to have a value for field "user" 
before this many-to-many relationship can be used.

Merchant have already been super saved. I can figure it out




On Wednesday, August 27, 2014 10:08:15 PM UTC+8, Collin Anderson wrote:
>
> i assume "groups" is an editable field in the admin.
>
> after the admin calls merchant.save(), it then clears out and re-assigns 
> the value of groups based on the data in the input field.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fcbff67e-a647-4701-9781-f7a860b0b6be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can not add a group to a custom auth user

2014-08-27 Thread Collin Anderson
i assume "groups" is an editable field in the admin.

after the admin calls merchant.save(), it then clears out and re-assigns 
the value of groups based on the data in the input field.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/40f10aed-6e0a-46d6-84e9-30dd3823ac54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can not add a group to a custom auth user

2014-08-26 Thread Ikaros andi


I want create a user with custom group in django admin. so I write below 
code:

from django.contrib.auth.models import User as AuthUserfrom 
django.contrib.auth.models import Group
# These groups have already been created while project start.class 
TestGroup(object):
Admin = 'Admin'
Merchant = 'Merchant'
User = 'User'
class Merchant(AuthUser):

def save(self, **kwargs):
super(Merchant, self).save(**kwargs)

for group in Group.objects.all():
print group.name

# way 1
if not self.groups.filter(name=TestGroup.Merchant).exists():
print self.groups.filter(name=TestGroup.Merchant).exists()
g = Group.objects.get(name=TestGroup.Merchant)
g.user_set.add(self)
print self.groups.filter(name=TestGroup.Merchant).exists()

# way 2
if not self.groups.filter(name=TestGroup.Merchant).exists():
g = Group.objects.get(name=TestGroup.Merchant)
self.groups.add(g)


# way 3
if not self.groups.filter(name=TestGroup.Merchant).exists():
g = Group.objects.get(name=TestGroup.Merchant)
self.groups.add(g)
self.save()

I have tried three ways to add a group to a user.But none of them could 
work.

*For Test:*

You can test by following this steps:

   1. 
   
   create a group named 'Merchant' at django admin
   2. 
   
   add my code (add print in way 1 to test), syncdb and so on.
   3. 
   
   create a Merchant at django admin. you can see log:
   
   u'Merchant'
   False
   True
   4. 
   
   enter the merchant you just created, you can see, the group merchant is 
   not selected(means this user do not beyond to this group).
   5. 
   
   click save again, you would still see
   
   u'Merchant'
   False
   True
   
add group to merchant fail, very strange.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6c880992-08f0-477d-a8dc-3b592695f49c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Custom auth backend and importing custom user model

2013-08-12 Thread Rok Jaklič
Hi,

I wrote custom auth backend, however when I try to import custom user model 
I get an error like:
ImportError: cannot import name "CustomUser" 

even though I have in custom_auth.py from users.models import CustomUser.

I found out that custom_auth.py is called before custom models.

Any ideas how could I solve this problem?

Kind regards,

Rok


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Override AdminAuthentication form for custom auth in Django Admin

2011-03-03 Thread Nick Serra
Hey everyone, thanks for looking.

Running into a problem getting the Django Admin working with a custom
auth system. Have everything working, but I cannot get the admin to
use my custom auth app to login. I am not running a custom auth
backend, but an entirely different auth app in my project. Basically I
need to override the admin's usage of the AdminAuthentication form in
the admin forms py. I can't think of any good way to do this. Any
suggestions? Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom auth backend and ./manage.py test

2010-02-21 Thread Mike Dewhirst

On 22/02/2010 10:53am, Stephen Crosby wrote:

I'm working on a project that requires a custom auth backend which
I've just written by subclassing contrib.auths.backends.ModelBackend
and overriding the authenticate method so it takes a third parameter.
It works nicely, but of course there are now lots of failed auth-
related tests because of the required third parameter to authenticate
when I run ./manage.py test. Related tests for my subclass of
contrib.auth.forms.AuthenticationForm also fail.

I'm just getting my feet wet with testing, so I don't know how to deal
with this properly. Can I override the default tests with new,
relevant ones? Should I just not subclass ModelBackend and
AuthenticationForm? Can I just tell django to skip certain tests?


I would leave existing tests to prove that the un-subclassed ancestral 
code stays wholesome and just write specific tests to prove your own new 
stuff.


hth

Mike




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



custom auth backend and ./manage.py test

2010-02-21 Thread Stephen Crosby
I'm working on a project that requires a custom auth backend which
I've just written by subclassing contrib.auths.backends.ModelBackend
and overriding the authenticate method so it takes a third parameter.
It works nicely, but of course there are now lots of failed auth-
related tests because of the required third parameter to authenticate
when I run ./manage.py test. Related tests for my subclass of
contrib.auth.forms.AuthenticationForm also fail.

I'm just getting my feet wet with testing, so I don't know how to deal
with this properly. Can I override the default tests with new,
relevant ones? Should I just not subclass ModelBackend and
AuthenticationForm? Can I just tell django to skip certain tests?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-10 Thread Shawn Milochik

The way to do what you're trying to do is to take advantage of the  
following:

http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

In brief, you'll create another model, which will then be specified in  
your settings.py by AUTH_PROFILE_MODULE. From then on, you will be  
able to use the contrib.auth.model.User  builtin function get_profile 
() to return your custom object.

You will not be subclassing the User model; there's no need, and it  
greatly complicates things to try. I'm currently working on doing this  
myself, because I am adding requirements for the password change.  
Namely, I need the password to expire after 90 days, I need the  
initial password to require a reset after the first successful login,  
and I need to enforce some rules about the complexity and non-reuse of  
the password.

Shawn

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-09 Thread Shawn Milochik
The way to do what you're trying to do is to take advantage of the  
following:

http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

In brief, you'll create another model, which will then be specified in  
your settings.py by AUTH_PROFILE_MODULE. From then on, you will be  
able to use the contrib.auth.model.User  builtin function  
get_profile() to
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-08 Thread Sandra Django
Hi, I want add a new attribute in User model and create custom backends.
Steep by steep, I did the following:
1) I created an application named "profile" into my project
2) I created, in models.py of "profile" a class named "UserProfile",
which inherits
from User class of Django. I added "press_agency" attribute, and I wrote
objects = UserManager()
3) I registered UserProfile and UserProfileAdmin classes in admin.py, and
unregistered User of Django.
4) Into my project, I created auth_backends.py file. You should see it here:
http://dpaste.com/hold/101036/
5) In settings.py I wrote:
AUTHENTICATION_BACKENDS = (
'myproject.auth_backends.CustomUserModelBackend', )
   CUSTOM_USER_MODEL = 'myproject.profile.UserProfile'

Then, when I go to login, write mi name and password, y the system returns
the following error:
'NoneType' object has no attribute 'DoesNotExist'
Why? What is the problem?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-02 Thread Sandra Django
Hi, I want add a new attribute in User model and create custom backends.
Steep by steep, I did the following:
1) I created an application named "profile" into my project
2) I created, in models.py of "profile" a class named "UserProfile",
which inherits
from User class of Django. I added "press_agency" attribute, and I wrote
objects = UserManager()
3) I registered UserProfile and UserProfileAdmin classes in admin.py, and
unregistered User of Django.
4) Into my project, I created auth_backends.py file. You should see it here:
http://dpaste.com/hold/101036/
5) In settings.py I wrote:
AUTHENTICATION_BACKENDS = (
'myproject.auth_backends.CustomUserModelBackend', )
   CUSTOM_USER_MODEL = 'myproject.profile.UserProfile'

Then, when I go to login, write mi name and password, y the system returns
the following error:
'NoneType' object has no attribute 'DoesNotExist'
Why? What is the problem?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auth test with custom auth backend

2009-08-25 Thread Joseph (Driftwood Cove Designs)

On Jul 26, 6:06 pm, Russell Keith-Magee 
wrote:
> One approach that may be worth considering is to look at whether you
> actually need to put contrib.authin INSTALLED APPS. If you're just
> using some of the backend utilities - such as the authentication
> backends - you may not need to sync theauthapplication itself.

I'm having a similar issue, but perhaps more subtle?
We are using contrib.auth to do most of the work, so it needs to be an
INSTALLED_APPS, but we use a custom backend to authenticate to a 3rd
party server.  This causes most of the auth tests to fail because they
assume (reasonably) that authentication is performed against the
auth_user data loaded from the fixture.
To solve this, I created a new setting, TESTING, and added the
following lines to my settings.py:

TESTING = True
AUTHENTICATION_BACKENDS = ('my.apps.auth.aashe.MyAuthBackend',)
if TESTING:
AUTHENTICATION_BACKENDS = AUTHENTICATION_BACKENDS +
('django.contrib.auth.backends.ModelBackend',)

In this way, when the custom backend fails to authenticate, the
default ModelBackend is consulted and the tests pass.  Then I added
additional tests specifically for our custom authentication backend.
Hoping this helps others.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auth test with custom auth backend

2009-07-27 Thread Vitaly Babiy
Yeah, I have thought about removing auth from my installed app but the
problem is I am going to be using the permissions part of the app.
Have the auth app support a custom model would be cool.

Also it might not be to bad to write a custom test runner that will ignore
test from apps listed in a setting config

Thank,
Vitaly Babiy


On Sun, Jul 26, 2009 at 9:06 PM, Russell Keith-Magee  wrote:

>
> On Mon, Jul 27, 2009 at 6:17 AM, Vitaly Babiy wrote:
> > Hey,
> > I have replaced the default auth backend with my own that requires a
> field
> > to be set on my own custom user objects. So when I run my test suite (
> which
> > includes the auth app ) most of the auth test fail. Due to the fact that
> > djangos fixtures don't create user object of my custom type. What is the
> > best way to work around this?
>
> There isn't really an easy workaround. If you put contrib.auth in your
> INSTALLED_APPS, Django assumes - somewhat reasonably - that you are
> using the User model.
>
> One approach that may be worth considering is to look at whether you
> actually need to put contrib.auth in INSTALLED APPS. If you're just
> using some of the backend utilities - such as the authentication
> backends - you may not need to sync the auth application itself.
>
> Beyond that, you're into slightly unexplored territory. The hardcore
> approach would be to just delete the tests directory from
> contrib.auth. This will make the test failure go away, but that's a
> bit like saying you can fix your long toenails by amputating your foot
> :-) There may be a less hardcore solution, but it will require some
> exploration on your part. It certainly isn't part of an official API
> at this point.
>
> This issue actually covers two problems that I'd like to address in
> the Django v1.2 timeframe. Firstly, differentiating between
> integration tests and release tests; secondly, making the User model
> truly pluggable, especially with respect to contrib.admin. Any
> feedback or input you have would be most welcome.
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Auth test with custom auth backend

2009-07-26 Thread Russell Keith-Magee

On Mon, Jul 27, 2009 at 6:17 AM, Vitaly Babiy wrote:
> Hey,
> I have replaced the default auth backend with my own that requires a field
> to be set on my own custom user objects. So when I run my test suite ( which
> includes the auth app ) most of the auth test fail. Due to the fact that
> djangos fixtures don't create user object of my custom type. What is the
> best way to work around this?

There isn't really an easy workaround. If you put contrib.auth in your
INSTALLED_APPS, Django assumes - somewhat reasonably - that you are
using the User model.

One approach that may be worth considering is to look at whether you
actually need to put contrib.auth in INSTALLED APPS. If you're just
using some of the backend utilities - such as the authentication
backends - you may not need to sync the auth application itself.

Beyond that, you're into slightly unexplored territory. The hardcore
approach would be to just delete the tests directory from
contrib.auth. This will make the test failure go away, but that's a
bit like saying you can fix your long toenails by amputating your foot
:-) There may be a less hardcore solution, but it will require some
exploration on your part. It certainly isn't part of an official API
at this point.

This issue actually covers two problems that I'd like to address in
the Django v1.2 timeframe. Firstly, differentiating between
integration tests and release tests; secondly, making the User model
truly pluggable, especially with respect to contrib.admin. Any
feedback or input you have would be most welcome.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Auth test with custom auth backend

2009-07-26 Thread Vitaly Babiy
Hey,
I have replaced the default auth backend with my own that requires a field
to be set on my own custom user objects. So when I run my test suite ( which
includes the auth app ) most of the auth test fail. Due to the fact that
djangos fixtures don't create user object of my custom type. What is the
best way to work around this?

Thanks,
Vitaly Babiy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom auth

2008-11-04 Thread Karen Tracey
On Tue, Nov 4, 2008 at 11:39 AM, Gabriel Rossetti <
[EMAIL PROTECTED]> wrote:

>
> Gabriel Rossetti wrote:
> > Hello everyone,
> >
> > I'm trying to get a custom auth handler to work but I keep on getting
> > this error when accessing request.user.get_profile() :
> >
> > DoesNotExist: User matching query does not exist.
> >
> > I followed the following tutorials :
> >
> > http://garage.pimentech.net/mdm_src_dj_auth_documentation/
> >
> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
> >
> > Here is my auth handler :
> >
> > from proj.app.models import User as MyUser
> > from django.contrib.auth.models import User, check_password
> >
> > def authenticate(self, username=None, password=None):
> > try:
> > myUser = MyUser.objects.get(email=username)
> > except MyUser.DoesNotExist:
> > return None
> > pwdValid = check_password(password, myUser.password)
> > if(pwdValid):
> > try:
> > user = User.objects.get(username=username)
> > except User.DoesNotExist:
> > user = User(username=username,
> > email=username,
> > first_name=myUser.firstName,
> > last_name=myUser.lastName,
> > password="none")
> > user.is_staff = False
> > user.is_superuser = False
> > user.save()
> > myUser.user = user # Not sure if this is really needed,
> > I tried it since it didn't work and it still doesn't
> > myUser.save() # Not sure if this is really needed, I
> > tried it since it didn't work and it still doesn't
> > return user
> > return None
> >
> > def get_user(self, userId):
> > try:
> > return User.objects.get(pk=userId)
> > except User.DoesNotExist:
> > return None
> >
> > here is my model :
> >
> > from django.db import models
> > from django.contrib.auth.models import User as DjangoUser
> >
> > class User(models.Model):
> > id = models.AutoField(primary_key=True)
> > firstname = models.CharField(maxlength=20)
> > lastname = models.CharField(maxlength=20)
> > email = models.CharField(maxlength=50)
> > password = models.CharField(maxlength=20)
> > user = models.ForeignKey(DjangoUser, unique=True)
> > #user = models.OneToOneField(DjangoUser, core=True) # This doesn't
> > work either
> >
> > I really don't see why it doesn't work...does anyone have a clue?
> >
> > Thank you,
> > Gabriel
> >
> > PS I've already looked at past posts on the subject but the common
> > answer is to create the profile, but in my case it's already created,
> > maybe I'm linking it wrong?
> >
> >
> Am I getting no responses because :
>
>   1) I missing something obvious
>   2) I said something wrong
>   3) The answer is so simple that no one wants to take the time to write it
>   4) No one has a clue
>   5) No on has the time
>   6) Another reason not listed here
>
>
It's a pretty safe bet that mostly people don't have the time for a question
that is sufficiently complicated/confusing to require more than a simple
answer.  From a high level it isn't immediately obvious how a custom
authenticate method can cause get_profile() to fail -- get_profile knows
nothing of custom authentication.  The error you are getting means that for
whatever user ID you are attempting get_profile() on, there is no record in
your custom User table (btw I find it confusing to name more than one model
the same thing and I think you are asking for trouble when you forget the
"as User" on your import of User somewhere) with that ID.

Looking at your custom authenticate, however, does provide some clues as to
what might have gone wrong -- you are doing more in authenticate than just
authenticating.  It appears you are auto-creating
django.contrib.auth.models.User objects to match your existing custom User
objects.  The lines you have that set the 'user' field in a  custom User
object and save it are necessary to link your custom User to the associated
Django user model, but from the comments it appears you did not have them
there initially.  Thus you may have created some number of Django user
objects without having set the appropriate value in the associated custom
user model.  Adding those lines after-the-fact won't fix the existing custom
User mod

Re: custom auth

2008-11-04 Thread Gabriel Rossetti

Gabriel Rossetti wrote:
> Hello everyone,
>
> I'm trying to get a custom auth handler to work but I keep on getting 
> this error when accessing request.user.get_profile() :
>
> DoesNotExist: User matching query does not exist.
>
> I followed the following tutorials :
>
> http://garage.pimentech.net/mdm_src_dj_auth_documentation/
> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
>
> Here is my auth handler :
>
> from proj.app.models import User as MyUser
> from django.contrib.auth.models import User, check_password
>
> def authenticate(self, username=None, password=None):
> try:
> myUser = MyUser.objects.get(email=username)
> except MyUser.DoesNotExist:
> return None
> pwdValid = check_password(password, myUser.password)
> if(pwdValid):
> try:
> user = User.objects.get(username=username)
> except User.DoesNotExist:
> user = User(username=username,
> email=username,
> first_name=myUser.firstName,
> last_name=myUser.lastName,
> password="none")
> user.is_staff = False
> user.is_superuser = False
> user.save()
> myUser.user = user # Not sure if this is really needed, 
> I tried it since it didn't work and it still doesn't
> myUser.save() # Not sure if this is really needed, I 
> tried it since it didn't work and it still doesn't
> return user
> return None
>
> def get_user(self, userId):
> try:
> return User.objects.get(pk=userId)
> except User.DoesNotExist:
> return None
>
> here is my model :
>
> from django.db import models
> from django.contrib.auth.models import User as DjangoUser
>
> class User(models.Model):
> id = models.AutoField(primary_key=True)
> firstname = models.CharField(maxlength=20)
> lastname = models.CharField(maxlength=20)
> email = models.CharField(maxlength=50)
> password = models.CharField(maxlength=20)
> user = models.ForeignKey(DjangoUser, unique=True)
> #user = models.OneToOneField(DjangoUser, core=True) # This doesn't 
> work either
>
> I really don't see why it doesn't work...does anyone have a clue?
>
> Thank you,
> Gabriel
>
> PS I've already looked at past posts on the subject but the common 
> answer is to create the profile, but in my case it's already created, 
> maybe I'm linking it wrong?
>
>   
Am I getting no responses because :

   1) I missing something obvious
   2) I said something wrong
   3) The answer is so simple that no one wants to take the time to write it
   4) No one has a clue
   5) No on has the time
   6) Another reason not listed here

:-)
Gabriel

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



custom auth

2008-10-30 Thread Gabriel Rossetti

Hello everyone,

I'm trying to get a custom auth handler to work but I keep on getting 
this error when accessing request.user.get_profile() :

DoesNotExist: User matching query does not exist.

I followed the following tutorials :

http://garage.pimentech.net/mdm_src_dj_auth_documentation/
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

Here is my auth handler :

from proj.app.models import User as MyUser
from django.contrib.auth.models import User, check_password

def authenticate(self, username=None, password=None):
try:
myUser = MyUser.objects.get(email=username)
except MyUser.DoesNotExist:
return None
pwdValid = check_password(password, myUser.password)
if(pwdValid):
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
user = User(username=username,
email=username,
first_name=myUser.firstName,
last_name=myUser.lastName,
password="none")
user.is_staff = False
user.is_superuser = False
user.save()
myUser.user = user # Not sure if this is really needed, 
I tried it since it didn't work and it still doesn't
myUser.save() # Not sure if this is really needed, I 
tried it since it didn't work and it still doesn't
return user
return None

def get_user(self, userId):
try:
return User.objects.get(pk=userId)
except User.DoesNotExist:
return None

here is my model :

from django.db import models
from django.contrib.auth.models import User as DjangoUser

class User(models.Model):
id = models.AutoField(primary_key=True)
firstname = models.CharField(maxlength=20)
lastname = models.CharField(maxlength=20)
email = models.CharField(maxlength=50)
password = models.CharField(maxlength=20)
user = models.ForeignKey(DjangoUser, unique=True)
#user = models.OneToOneField(DjangoUser, core=True) # This doesn't 
work either

I really don't see why it doesn't work...does anyone have a clue?

Thank you,
Gabriel

PS I've already looked at past posts on the subject but the common 
answer is to create the profile, but in my case it's already created, 
maybe I'm linking it wrong?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---