#NEWLINE# def _login( request , provider ) : #NEWLINE# #INDENT# if getattr ( settings , 'SANCTION_USE_CSRF' , True ) : #NEWLINE# #INDENT# if ( not ( 'state' in request . GET ) ) : #NEWLINE# #INDENT# logging . error ( 'SANCTION_USE_CSRF=True but "state" not defined in GET' ) #NEWLINE# raise PermissionDenied #NEWLINE# #UNINDENT# if ( not constant_time_compare ( csrf . get_token ( request ) , request . GET [ 'state' ] ) ) : #NEWLINE# #INDENT# logging . error ( 'state GET param does not match session state' ) #NEWLINE# raise PermissionDenied #NEWLINE# #UNINDENT# #UNINDENT# user = authenticate ( code = request . GET [ 'code' ] , provider_key = provider ) #NEWLINE# if ( user is not None ) : #NEWLINE# #INDENT# request . session [ '__sp' ] = provider #NEWLINE# django_login ( request , request ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( 'Unable to authenticate user' ) #NEWLINE# raise PermissionDenied #NEWLINE# #UNINDENT# return redirect ( settings . LOGIN_REDIRECT_URL )