def post(self, request): """Create/Edit items.""" form = yield from self.get_form(request) if not form.validate(): raise muffin.HTTPBadRequest( text=json.dumps(form.errors), content_type='application/json') yield from self.save_form(form, request) raise muffin.HTTPFound(self.url)
def login_post(request): data = yield from request.post() user = store.get("/user/" + data.get("username", "")) if user is None: return app.ps.pystache.render("login", page_title="Login", error_message="Invalid user name.") data, errmsg = models.LoginForm.from_form(data) if data is None: pass elif user.password != data.password: errmsg = "Invalid password." elif not user.totp_verify(data.otptoken): errmsg = "Invalid token." else: yield from app.ps.session.login(request, user.username) return muffin.HTTPFound("/") return app.ps.pystache.render("login", page_title="Login", username=(data.username if data else ""), error_message=errmsg)
def logout(request): yield from app.ps.session.logout(request) return muffin.HTTPFound("/")
def login(request): yield from app.ps.session.login(request, request.GET.get('name')) return muffin.HTTPFound('/auth')
def bulk_delete(handler, request): """Bulk delete items""" ids = request.GET.getall('ids') Message.delete().where(Message.id << ids).execute() raise muffin.HTTPFound(handler.url)