def index(): email_id = is_logged_in(request, online_users) log.info("good user: %s", email_id) if email_id is None: redirect("/u/form/login") return PageData(user=user_map[email_id], url_map=url_map).__dict__
def shorten_url(): if request.headers.get("Content-Type") != "application/json": return dict(error="Request must be a json object.") email_id = is_logged_in(request, online_users) if email_id is None: redirect("/u/form/login")
def form_login(): email_id = is_logged_in(request, online_users) log.info("login good user: %s", email_id) if email_id is not None: redirect("/") return dict()
def del_url(short_url): email_id = is_logged_in(request, online_users) if email_id is None: redirect("/u/form/login") success = delete_short_url(user_map[email_id], url_map, short_url) if success: return return_json({'success': success}) else: abort(405, "{success:false}")
def login(): userid = u.is_logged_in(b.request, online_users) if userid is not None: b.redirect("/") email_id = b.request.forms.get('email_id') passwd = b.request.forms.get('passwd') person_id = u.is_correct_login(email_id, passwd, user_passwds) if person_id: online_users[email_id] = (person_id, time.time()) b.response.set_cookie('email_id', str(email_id)) b.redirect(f"/person/{person_id}") else: b.abort(404, "Wrong Email/Passwd!")
def login(): email_id = is_logged_in(request, online_users) if email_id is not None: redirect("/") email_id = request.forms.get('email_id') passwd = request.forms.get('passwd') email_id = is_correct_login(email_id, passwd, user_map) if email_id: online_users[email_id] = time.time() response.set_cookie('email_id', str(email_id), path="/") redirect("/") else: abort(404, "Wrong Email/Passwd!")
def person(person_id): log.info("try page person_id : %s", person_id) userid = u.is_logged_in(b.request, online_users) if userid is None: b.abort(404, "Not logged in / idle for too long!") if person_id in people: pd = PageData() pd.person = people[person_id] pd.relatives = u.fetch_family(pd.person, people) pic_dir = u.person_dir(person_id) pd.pics = u.pics_path(pic_dir, pd.person) pd.family = u.fetch_family(pd.person, people) # pd.profile_pic = u.profile_pic_path(pic_dir, person_id) # pd.avatar_pic = u.avatar_pic_path(pic_dir, person_id) # (pd.avatar_pic, pd.profile_pic) = u.random_avatar_profile_pic() log.info("avatar = %s, profile = %s, pics = %s", pd.avatar_pic, pd.profile_pic, pd.pics) return pd.__dict__ b.abort(404, "Person not found!")
def logout(): userid = u.is_logged_in(b.request, online_users) if userid is not None: b.response.set_cookie('email_id', "None") b.redirect("/")
def do_login(): userid = u.is_logged_in(b.request, online_users) if userid is None: b.redirect("/person/{userid}") else: b.redirect("/")
def index(): userid = u.is_logged_in(b.request, online_users) if userid is not None: b.redirect("/person/{}".format(userid)) return dict()
def logout(): email_id = is_logged_in(request, online_users) if email_id is not None: response.set_cookie('email_id', "None") redirect("/u/login-form")
def form_register(): email_id = is_logged_in(request, online_users) if email_id is not None: redirect("/") return dict()