Skip to content

Instantly share code, notes, and snippets.

@waltermoreira
Created June 9, 2020 20:46
Show Gist options
  • Save waltermoreira/8f4f513a870afe787edffa910949818e to your computer and use it in GitHub Desktop.
Save waltermoreira/8f4f513a870afe787edffa910949818e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import shell"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def get_login_cookie(shell_instance: shell.Shell, email: str) -> str:\n",
" \n",
" @shell_instance.ab_decorator\n",
" def _get_cookie(email):\n",
" from data_access.models.user import User\n",
" from google.appengine.ext import ndb\n",
"\n",
" u = User(username=email).get()\n",
" s = ndb.Key(urlsafe=u.seeker_key).get()\n",
" handler.user_attributes.add_seeker_to_session(s, handler.request)\n",
" return str(handler.user_attributes), handler.user_attributes.cookie\n",
"\n",
" return _get_cookie"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sh = shell.Shell(\"searchbertha-qa1\", \"29\", \"jwt\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"cookie = get_login_cookie(sh, \"jkemp@auntbertha.com\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"%reload_ext shell\n",
"# searchbertha-qa1\n",
"# 29\n",
"# jwt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%ab\n",
"handler.user_attributes"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment