<s> import logging <EOL> from django import http <EOL> from django import template <EOL> from django . conf import settings <EOL> from django . template import loader <EOL> from django . core . cache import cache <EOL> from google . appengine . api import users <EOL> from common import api <EOL> from common import clean <EOL> from common import decorator <EOL> from common import exception <EOL> from common import user <EOL> from common import util <EOL> from common . exception import logging <EOL> from common import views as common_views <EOL> @ decorator . cache_never <EOL> def login_login ( request ) : <EOL> redirect_to = request . REQUEST . get ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> redirect_to = clean . redirect_to ( redirect_to ) <EOL> if request . POST : <EOL> try : <EOL> login = request . POST . get ( '<STR_LIT>' , None ) <EOL> password = request . POST . get ( '<STR_LIT>' , None ) <EOL> rememberme = request . POST . get ( '<STR_LIT>' , None ) <EOL> current_user = user . lookup_user_by_login ( login , password ) <EOL> if current_user : <EOL> if redirect_to == '<STR_LIT:/>' : <EOL> redirect_to = current_user . url ( '<STR_LIT>' ) <EOL> api . user_cleanup ( api . ROOT , current_user . nick ) <EOL> if ( not settings . HOSTED_DOMAIN_ENABLED <EOL> or not settings . SSL_LOGIN_ENABLED ) : <EOL> response = http . HttpResponseRedirect ( redirect_to ) <EOL> response = user . set_user_cookie ( response , current_user , rememberme ) <EOL> return response <EOL> sso_token = util . generate_uuid ( ) <EOL> cache . set ( '<STR_LIT>' % sso_token , ( current_user . nick , rememberme ) , timeout = <NUM_LIT:10> ) <EOL> sso_url = '<STR_LIT>' % ( settings . DOMAIN ) <EOL> sso_url = util . qsa ( <EOL> sso_url , { '<STR_LIT>' : redirect_to , '<STR_LIT>' : sso_token } ) <EOL> return http . HttpResponseRedirect ( sso_url ) <EOL> else : <EOL> raise exception . ValidationError ( "<STR_LIT>" ) <EOL> except : <EOL> exception . handle_exception ( request ) <EOL> view = user . get_user_from_cookie_or_legacy_auth ( request ) <EOL> area = "<STR_LIT>" <EOL> if view : <EOL> if redirect_to == '<STR_LIT:/>' : <EOL> redirect_to = request . user . url ( '<STR_LIT>' ) <EOL> return http . HttpResponseRedirect ( redirect_to ) <EOL> c = template . RequestContext ( request , locals ( ) ) <EOL> t = loader . get_template ( '<STR_LIT>' ) <EOL> return http . HttpResponse ( t . render ( c ) ) <EOL> @ decorator . cache_never <EOL> def login_noreally ( request ) : <EOL> if '<STR_LIT>' in request . GET : <EOL> sso_token = request . GET [ '<STR_LIT>' ] <EOL> redirect_to = request . GET [ '<STR_LIT>' ] <EOL> redirect_to = clean . redirect_to ( redirect_to ) <EOL> nick , rememberme = cache . get ( '<STR_LIT>' % sso_token ) <EOL> cache . delete ( '<STR_LIT>' % sso_token ) <EOL> actor_ref = api . actor_get ( api . ROOT , nick ) <EOL> response = http . HttpResponseRedirect ( redirect_to ) <EOL> response = user . set_user_cookie ( response , actor_ref , rememberme ) <EOL> return response <EOL> return http . HttpResponseRedirect ( '<STR_LIT>' ) <EOL> @ decorator . cache_never <EOL> def login_logout ( request ) : <EOL> request . user = None <EOL> redirect_to = '<STR_LIT:/>' <EOL> flash = "<STR_LIT>" % util . get_metadata ( '<STR_LIT>' ) <EOL> c = template . RequestContext ( request , locals ( ) ) <EOL> t = loader . get_template ( '<STR_LIT>' ) <EOL> response = util . RedirectFlash ( redirect_to , flash ) <EOL> response = user . clear_user_cookie ( response ) <EOL> return response <EOL> def login_forgot ( request ) : <EOL> if request . user : <EOL> raise exception . AlreadyLoggedInException ( ) <EOL> handled = common_views . handle_view_action ( <EOL> request , { '<STR_LIT>' : request . path , } ) <EOL> if handled : <EOL> return handled <EOL> c = template . RequestContext ( request , locals ( ) ) <EOL> t = loader . get_template ( '<STR_LIT>' ) <EOL> response = http . HttpResponse ( t . render ( c ) ) <EOL> return response <EOL> def login_reset ( request ) : <EOL> new_password , nick = api . login_reset ( <EOL> None , request . GET . get ( '<STR_LIT:email>' ) , request . GET . get ( '<STR_LIT>' ) ) <EOL> c = template . RequestContext ( request , locals ( ) ) <EOL> t = loader . get_template ( '<STR_LIT>' ) <EOL> response = http . HttpResponse ( t . render ( c ) ) <EOL> return response </s>
