(self)
| 235 | self.render("create_author.html") |
| 236 | |
| 237 | async def post(self): |
| 238 | if await self.any_author_exists(): |
| 239 | raise tornado.web.HTTPError(400, "author already created") |
| 240 | hashed_password = await tornado.ioloop.IOLoop.current().run_in_executor( |
| 241 | None, |
| 242 | bcrypt.hashpw, |
| 243 | tornado.escape.utf8(self.get_argument("password")), |
| 244 | bcrypt.gensalt(), |
| 245 | ) |
| 246 | author = await self.queryone( |
| 247 | "INSERT INTO authors (email, name, hashed_password) " |
| 248 | "VALUES (%s, %s, %s) RETURNING id", |
| 249 | self.get_argument("email"), |
| 250 | self.get_argument("name"), |
| 251 | tornado.escape.to_unicode(hashed_password), |
| 252 | ) |
| 253 | self.set_signed_cookie("blogdemo_user", str(author.id)) |
| 254 | self.redirect_to_next() |
| 255 | |
| 256 | |
| 257 | class AuthLoginHandler(BaseHandler): |
nothing calls this directly
no test coverage detected