def provision(): # retrieves the complete set of data from the request # and then unpacks it into the expected attributes heroku_id = quorum.get_field("heroku_id") plan = quorum.get_field("plan") # creates the heroku account with the unpacked values from the # provided message account = models.Account.create_heroku(heroku_id, plan = plan) # schedules the execution of the server creation for # the current provision, this will be deferred so that # the call is only made after provision is complete quorum.run_back( create_servers_h, args = (heroku_id, account) ) return flask.Response( json.dumps({ "id" : heroku_id, "config" : { "PINGU_API_KEY" : account.api_key, "PINGU_APP_ID" : heroku_id } }), mimetype = "application/json" )
def sso_login(): # retrieves the various parameters provided by the # caller post operation to be used in the construction # of the response and security validations id = quorum.get_field("id") timestamp = quorum.get_field("timestamp") token = quorum.get_field("token") nav_data = quorum.get_field("nav-data") # runs the sso login for the provided arguments and retrieves # the account that has just been logged in account = models.Account.sso_login(id, timestamp, token, nav_data) # retrieves the contents to be use in the navigation bar for the # heroku session navbar_h = get_navbar_h() # updates the current user (name) in session with # the username that has just be accepted in the login flask.session["username"] = account.username flask.session["tokens"] = account.tokens flask.session["instance_id"] = account.instance_id flask.session["nav_data"] = navbar_h # makes the current session permanent this will allow # the session to persist along multiple browser initialization flask.session.permanent = True # creates a new redirect request and uses it to create # the response object that is set with the cookie value # to be used by heroku navigation bar redirect = flask.redirect(flask.url_for("list_servers")) response = flask.make_response(redirect) response.set_cookie("heroku-nav-data", value=nav_data) return response
def login(): username = quorum.get_field("username") password = quorum.get_field("password") try: account = models.Account.login(username, password) except quorum.OperationalError as error: return flask.render_template( "signin.html.tpl", username = username, error = error.message ) # updates the current user (name) in session with # the username that has just be accepted in the login flask.session["username"] = account.username flask.session["tokens"] = account.tokens flask.session["instance_id"] = account.instance_id flask.session["nav_data"] = None # makes the current session permanent this will allow # the session to persist along multiple browser initialization flask.session.permanent = True return flask.redirect( flask.url_for("index") )
def plan_change(id): plan = quorum.get_field("plan") account = models.Account.get(username = id) account.plan = plan account.save() return "ok"
def plan_change(id): plan = quorum.get_field("plan") account = models.Account.get(username=id) account.plan = plan account.save() return "ok"
def provision(): # retrieves the complete set of data from the request # and then unpacks it into the expected attributes heroku_id = quorum.get_field("heroku_id") plan = quorum.get_field("plan") # creates the heroku account with the unpacked values from the # provided message account = models.Account.create_heroku(heroku_id, plan=plan) # schedules the execution of the server creation for # the current provision, this will be deferred so that # the call is only made after provision is complete quorum.run_back(create_servers_h, args=(heroku_id, account)) return flask.Response(json.dumps({ "id": heroku_id, "config": { "PINGU_API_KEY": account.api_key, "PINGU_APP_ID": heroku_id } }), mimetype="application/json")
def sso_login(): # retrieves the various parameters provided by the # caller post operation to be used in the construction # of the response and security validations id = quorum.get_field("id") timestamp = quorum.get_field("timestamp") token = quorum.get_field("token") nav_data = quorum.get_field("nav-data") # runs the sso login for the provided arguments and retrieves # the account that has just been logged in account = models.Account.sso_login(id, timestamp, token, nav_data) # retrieves the contents to be use in the navigation bar for the # heroku session navbar_h = get_navbar_h() # updates the current user (name) in session with # the username that has just be accepted in the login flask.session["username"] = account.username flask.session["tokens"] = account.tokens flask.session["instance_id"] = account.instance_id flask.session["nav_data"] = navbar_h # makes the current session permanent this will allow # the session to persist along multiple browser initialization flask.session.permanent = True # creates a new redirect request and uses it to create # the response object that is set with the cookie value # to be used by heroku navigation bar redirect = flask.redirect( flask.url_for("list_servers") ) response = flask.make_response(redirect) response.set_cookie("heroku-nav-data", value = nav_data) return response