Exemple #1
0
def login():

    if 'store' in session:
        return redirect(url_for('store.view'))

    if request.method == 'POST':
        # Get the base app credentials
        credentials = app.config.get('SHOPIFY_CREDENTIALS')

        #Setup a session to store the shop_name
        session['shop_name'] = shop_name = request.form['shop_name']

        #Setup a shopify adapter instance to create the authorization url
        shopify = Shopify(shop_name=shop_name, credentials=credentials)

        #Generate a url pointing back to an action on this blueprint
        redirect_to = url_for('.shopify_callback', _external=True)

        #Generate the oauth authorization url with a redirection to our app
        oauth_url = shopify.oauth_authorize_url(
            redirect_to=redirect_to
        )

        return redirect(oauth_url)

    return render_template('auth/login.html')