def login(redirect_after=None): jwt = request.args.get("jwt", False) if not jwt: return force_auth() r = registry_request("/auth/profile.json", jwt) try: profile = r.json() conn = Connection() conn.token = b64encode(urandom(30))[:30] conn.logged_in = datetime.datetime.now() conn.last_click = conn.logged_in conn.remote_addr = request.remote_addr conn.user_id = profile["person"]["id"] conn.name = profile["person"]["name"] conn.profile = r.text conn.jwt = jwt db.session.add(conn) db.session.commit() session["conn_id"] = conn.id session["conn_token"] = conn.token if redirect_after: return redirect(b64decode(redirect_after)) return redirect(url_for("index")) except: raise return force_auth()
def registry_person(user_id): return registry_request("/people/{}.json".format(user_id)).text
def registry_people(): return registry_request("/people.json").text