Allow overriding view authentication system
This commit is contained in:
		
							parent
							
								
									a97004ddc7
								
							
						
					
					
						commit
						40946be0e6
					
				| 
						 | 
					@ -83,7 +83,7 @@ class GASMixin:
 | 
				
			||||||
    breadcrumbs = []
 | 
					    breadcrumbs = []
 | 
				
			||||||
    actions = None
 | 
					    actions = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def dispatch(self, *args, **kwargs):
 | 
					    def check_user_forbidden(self):
 | 
				
			||||||
        user = self.request.user
 | 
					        user = self.request.user
 | 
				
			||||||
        roles = set(self.roles)
 | 
					        roles = set(self.roles)
 | 
				
			||||||
        roles.add(self.base_role)
 | 
					        roles.add(self.base_role)
 | 
				
			||||||
| 
						 | 
					@ -93,7 +93,10 @@ class GASMixin:
 | 
				
			||||||
                and user.user_roles.filter(role__in=roles).count() == 0
 | 
					                and user.user_roles.filter(role__in=roles).count() == 0
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        if access_denied:
 | 
					        return access_denied
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def dispatch(self, *args, **kwargs):
 | 
				
			||||||
 | 
					        if self.check_user_forbidden():
 | 
				
			||||||
            return HttpResponseRedirect(reverse('gas:login') + '?next={}'.format(self.request.path))
 | 
					            return HttpResponseRedirect(reverse('gas:login') + '?next={}'.format(self.request.path))
 | 
				
			||||||
        return super().dispatch(*args, **kwargs)
 | 
					        return super().dispatch(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue