 from django . conf import settings <EOL> from django . contrib import messages <EOL> from django . contrib . auth import authenticate , login , logout <EOL> from django . http import HttpResponseRedirect <EOL> from django . utils . translation import ugettext_lazy as _lazy <EOL> from kitsune . sumo . urlresolvers import reverse <EOL> class TokenLoginMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> try : <EOL> auth = request . GET . get ( '<STR_LIT>' ) <EOL> except IOError : <EOL> return <EOL> if auth is None or ( request . user and request . user . is_authenticated ( ) ) : <EOL> return <EOL> user = authenticate ( auth = auth ) <EOL> if user and user . is_active : <EOL> login ( request , user ) <EOL> msg = _lazy ( u'<STR_LIT>' ) 
 messages . success ( request , msg ) 
 from django . conf import settings <EOL> from django . contrib import messages <EOL> from django . contrib . auth import authenticate , login , logout <EOL> from django . http import HttpResponseRedirect <EOL> from django . utils . translation import ugettext_lazy as _lazy <EOL> from kitsune . sumo . urlresolvers import reverse <EOL> class TokenLoginMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> try : <EOL> auth = request . GET . get ( '<STR_LIT>' ) <EOL> except IOError : <EOL> return <EOL> if auth is None or ( request . user and request . user . is_authenticated ( ) ) : <EOL> return <EOL> user = authenticate ( auth = auth ) <EOL> if user and user . is_active : <EOL> login ( request , user ) <EOL> msg = _lazy ( u'<STR_LIT>' ) <EOL> messages . success ( request , msg ) <EOL> class LogoutDeactivatedUsersMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_request ( self , request ) : <EOL> user = request . user <EOL> if ( user . is_authenticated ( ) and not user . is_active and <EOL> not request . session . get ( '<STR_LIT>' , False ) ) : <EOL> logout ( request ) <EOL> res = HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> res . delete_cookie ( settings . SESSION_EXISTS_COOKIE ) <EOL> return res </s>
