<s> from django_roa . remoteauth . models import User <EOL> from django . contrib . auth . backends import ModelBackend <EOL> class RemoteUserModelBackend ( ModelBackend ) : <EOL> """<STR_LIT>""" <EOL> def authenticate ( self , username = None , password = None , ** kwargs ) : <EOL> try : <EOL> user = User . objects . get ( username = username ) <EOL> if user . check_password ( password ) : <EOL> return user <EOL> except User . DoesNotExist : <EOL> return None <EOL> def get_group_permissions ( self , user_obj , obj = None ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( user_obj , '<STR_LIT>' ) : <EOL> permissions = [ u"<STR_LIT>" % ( p . content_type . app_label , p . codename ) for group in user_obj . groups . all ( ) for p in group . permissions . all ( ) ] <EOL> user_obj . _group_perm_cache = permissions <EOL> return user_obj . _group_perm_cache <EOL> def get_user ( self , user_id ) : <EOL> try : <EOL> return User . objects . get ( pk = user_id ) <EOL> except User . DoesNotExist : <EOL> return None </s>
