<s> from . . utils import LazyUser , eval_url <EOL> def setup_for_flask ( <EOL> auth , app , send_email = None , render = None , <EOL> session = None , request = None , urloptions = None ) : <EOL> import flask <EOL> auth . request = request or flask . request <EOL> if session is not None : <EOL> auth . session = session <EOL> else : <EOL> auth . session = flask . session <EOL> if send_email : <EOL> auth . send_email = send_email <EOL> auth . render = render or flask . render_template <EOL> app . jinja_env . globals [ '<STR_LIT>' ] = auth . get_csrf_token <EOL> app . jinja_env . globals [ '<STR_LIT>' ] = auth <EOL> def set_user ( ) : <EOL> LazyUser ( auth , flask . g , user_name = auth . user_name ) <EOL> app . before_request_funcs . setdefault ( None , [ ] ) . insert ( <NUM_LIT:0> , set_user ) <EOL> if auth . views : <EOL> assert auth . render <EOL> setup_for_flask_views ( auth , app , urloptions ) <EOL> def setup_for_flask_views ( auth , app , urloptions ) : <EOL> urloptions = urloptions or { } <EOL> if '<STR_LIT>' in auth . views : <EOL> url_sign_in = eval_url ( auth . url_sign_in ) <EOL> app . route ( <EOL> url_sign_in , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = '<STR_LIT>' . format ( <EOL> prefix = auth . views_prefix , name = '<STR_LIT>' ) , <EOL> ** urloptions <EOL> ) ( auth . auth_sign_in ) <EOL> if '<STR_LIT>' in auth . views : <EOL> url_sign_out = eval_url ( auth . url_sign_out ) <EOL> app . route ( <EOL> url_sign_out , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = '<STR_LIT>' . format ( <EOL> prefix = auth . views_prefix , name = '<STR_LIT>' ) , <EOL> ** urloptions <EOL> ) ( auth . auth_sign_out ) <EOL> if '<STR_LIT>' in auth . views : <EOL> url_change_password = eval_url ( auth . url_change_password ) <EOL> app . route ( <EOL> url_change_password , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = '<STR_LIT>' . format ( <EOL> prefix = auth . views_prefix , name = '<STR_LIT>' ) , <EOL> ** urloptions <EOL> ) ( auth . auth_change_password ) <EOL> if '<STR_LIT>' in auth . views : <EOL> url_reset_password = eval_url ( auth . url_reset_password ) <EOL> app . route ( <EOL> url_reset_password , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = '<STR_LIT>' . format ( <EOL> prefix = auth . views_prefix , name = '<STR_LIT>' ) , <EOL> ** urloptions <EOL> ) ( auth . auth_reset_password ) <EOL> app . route ( <EOL> url_reset_password . rstrip ( '<STR_LIT:/>' ) + '<STR_LIT>' , <EOL> methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] , <EOL> endpoint = '<STR_LIT>' . format ( <EOL> prefix = auth . views_prefix , name = '<STR_LIT>' ) , <EOL> ** urloptions <EOL> ) ( auth . auth_reset_password ) </s>
