#NEWLINE# def post( self , request , assertion ) : #NEWLINE# #INDENT# 'Logs a user in (establishes a session cookie).\n\n        Verifies BrowserID assertion and check that a user with an\n        email verified by the BrowserID is known (added to users\n        list).\n        ' #NEWLINE# if ( assertion == None ) : #NEWLINE# #INDENT# return http . HttpResponseBadRequest ( 'BrowserId assertion not set.' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user = auth . authenticate ( site = request . site , site_url = request . site_url , assertion = assertion ) #NEWLINE# #UNINDENT# except AuthenticationError as ex : #NEWLINE# #INDENT# logger . debug ( 'Assertion verification failed.' ) #NEWLINE# return http . HttpResponseBadRequest ( str ( ex ) ) #NEWLINE# #UNINDENT# if ( user is not None ) : #NEWLINE# #INDENT# auth . login ( request , user ) #NEWLINE# request . session [ 'user_id' ] = user . id #NEWLINE# logger . debug ( ( '%s successfully logged.' % user . email ) ) #NEWLINE# return http . HttpResponseNoContent ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return http . HttpResponseNotAuthorized ( )