Hi Malcolm, Thanks for your clear explanation. I've already done the authorization function by myself, if you are interesting in it, you could refer to following coding. After analysising django's auth module, I just gave it up for some integration reason. However, I copied some useful function from that into my auth application. As of the current testing, it works well.
+++++++++++++++++++++++++++ >>MODEL:( I just eliminate model's attributioin for saving the timing of >>reading) class Group(models.Model): group_id=models.CharField(_('Group ID'),max_length=8,unique=True) group_desc=models.CharField(_('Group Description'),max_length=30,unique=True) class View(models.Model): """Define which model can be accessed for updating or just viewing""" group=models.ForeignKey(Group,verbose_name=_ ('Group'),related_name='view') view_label=models.CharField(_('Group Views'),max_length=20) auth_type=models.CharField(_('Access Type'),max_length=1,choices=AUTH_TYPE) class Scope(models.Model): """Define in which scope(based on code) can be visited by certain user""" group=models.ForeignKey(Group,verbose_name=_ ('Group'),related_name='scope') code=models.ForeignKey(Code,verbose_name=_ ('Code'),related_name='scope') class User(models.Model): user_id=models.CharField(_('User ID'),max_length=8,unique=True) user_name=models.CharField(_('User Name'),max_length=30) group=models.ForeignKey(Group,verbose_name=_ ('Group'),related_name='user') birthday=models.DateField(_('Birthday')) email=models.EmailField(_('email')) password=models.CharField(_ ('Password'),max_length=80,editable=False,unique=True,default=make_random_password (length=60)) effective_date=models.DateField(_('Effective Date'),auto_now_add=True) last_login=models.DateTimeField(_('Last Login Date'),editable=False,default='1900-01-01') error_login=models.PositiveSmallIntegerField(_('Error Login'),editable=False,default='0') status=models.CharField(_ ('Status'),max_length=1,choices=STATUS_CHOICES) fav=models.CharField(_('My Favorite'),max_length=200,blank=True) >>LOG IN VIEW: def login(request,template='auths/login.html',url_after_login='/ welcome/'): if if_setlang(request):return setlang(request)#for language selection empty_form=LoginForm() if request.method=='POST': form=LoginForm(request.POST) if form.is_valid(): userid,password=request.POST['username'],request.POST ['password'] userdata=User.objects.filter(user_id__exact=userid) if userdata:#1.1 _today=datetime.date.today() for i in userdata: _status=i.status if i.check_password(password):#1.1 if password is correct i.last_login=_today i.save() if i.status=='S':#1.1.1 checking status first return render_to_response(template, {'form':empty_form,'error_msg':msg_suspend}) elif i.password_expired():#1.1.2 checking password expiration return render_to_response(template, {'form':empty_form,'error_msg':msg_expire}) else: i.error_login=0 i.save() request.session['user_id'] = userid request.session['scope']=scopeset(userid) write_log(request,'','Log In',log_level=1) #>>writing Log return HttpResponseRedirect (url_after_login) else:#1.2 password is incorrect i.error_login+=1 psw_times=TIMES_ERROR_LOGIN-i.error_login if i.error_login>=TIMES_ERROR_LOGIN: psw_times,i.status=0,'S' i.save() error_msg=msg_incorrect if psw_times!=0 else msg_suspend #msg_incorrect%(psw_times) return render_to_response(template, {'form':empty_form,'error_msg':error_msg}) else:#2 user doesn't exist in database return render_to_response(template, {'form':empty_form,"error_msg":msg_na}) return render_to_response(template, {'form':empty_form,'error_msg':msg_invalid}) else: return render_to_response(template,{'form':empty_form}) ++++++++++++++++++++++++++++++++++++++++++++ Regards, Zeal Hua --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---