<s> """<STR_LIT>""" <EOL> from django . contrib import messages <EOL> from django . shortcuts import redirect <EOL> from social . apps . django_app . middleware import SocialAuthExceptionMiddleware <EOL> from django . http import HttpResponse <EOL> from social import exceptions as social_exceptions <EOL> from social . exceptions import AuthCanceled , AuthAlreadyAssociated , NotAllowedToDisconnect <EOL> class TethysSocialAuthExceptionMiddleware ( SocialAuthExceptionMiddleware ) : <EOL> def process_exception ( self , request , exception ) : <EOL> if hasattr ( social_exceptions , exception . __class__ . __name__ ) : <EOL> if isinstance ( exception , AuthCanceled ) : <EOL> if request . user . is_anonymous ( ) : <EOL> return redirect ( '<STR_LIT>' ) <EOL> else : <EOL> return redirect ( '<STR_LIT>' , username = request . user . username ) <EOL> elif isinstance ( exception , AuthAlreadyAssociated ) : <EOL> blurb = '<STR_LIT>' <EOL> print ( exception . backend . name ) <EOL> if '<STR_LIT>' in exception . backend . name : <EOL> blurb = blurb . format ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in exception . backend . name : <EOL> blurb = blurb . format ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in exception . backend . name : <EOL> blurb = blurb . format ( '<STR_LIT>' ) <EOL> elif '<STR_LIT>' in exception . backend . name : <EOL> blurb = blurb . format ( '<STR_LIT>' ) <EOL> else : <EOL> blurb = blurb . format ( '<STR_LIT>' ) <EOL> messages . success ( request , blurb ) <EOL> if request . user . is_anonymous ( ) : <EOL> return redirect ( '<STR_LIT>' ) <EOL> else : <EOL> return redirect ( '<STR_LIT>' , username = request . user . username ) <EOL> elif isinstance ( exception , NotAllowedToDisconnect ) : <EOL> blurb = '<STR_LIT>' <EOL> messages . success ( request , blurb ) <EOL> if request . user . is_anonymous ( ) : <EOL> return redirect ( '<STR_LIT>' ) <EOL> else : <EOL> return redirect ( '<STR_LIT>' , username = request . user . username ) </s>
