#NEWLINE# @ admin . route ( '/login' ) #NEWLINE# def login( ) : #NEWLINE# #INDENT# me = request . args . get ( 'me' ) #NEWLINE# if ( not me ) : #NEWLINE# #INDENT# return render_template ( 'admin/login.jinja2' , next = request . args . get ( 'next' ) ) #NEWLINE# #UNINDENT# if ( not me ) : #NEWLINE# #INDENT# return make_response ( 'Missing "me" parameter' , 400 ) #NEWLINE# #UNINDENT# if ( ( not me . startswith ( 'http://' ) ) and ( not me . startswith ( 'https://' ) ) ) : #NEWLINE# #INDENT# me = ( 'http://' + me ) #NEWLINE# #UNINDENT# ( auth_url , token_url , micropub_url ) = discover_endpoints ( me ) #NEWLINE# if ( not auth_url ) : #NEWLINE# #INDENT# auth_url = 'https://indieauth.com/auth' #NEWLINE# #UNINDENT# current_app . logger . debug ( 'Found endpoints %s, %s, %s' , auth_url , token_url , micropub_url ) #NEWLINE# state = request . args . get ( 'next' ) #NEWLINE# session [ 'endpoints' ] = ( auth_url , token_url , micropub_url ) #NEWLINE# auth_params = { #NEWLINE# #INDENT# 'me' : me , #NEWLINE# 'client_id' : get_settings ( ) . site_url , #NEWLINE# 'redirect_uri' : url_for ( '.login_callback' , _external = True ) , #NEWLINE# 'state' : state , #NEWLINE# #UNINDENT# } #NEWLINE# if ( token_url and micropub_url ) : #NEWLINE# #INDENT# auth_params [ 'scope' ] = 'config' #NEWLINE# #UNINDENT# return redirect ( '{}?{}' . format ( auth_url , urllib . parse . urlencode ( auth_params ) ) )