Esempio n. 1
0
    def post(self):
        """
        Args:
            username
            password
        """

        if self.db.query(User).filter(User.name == self.get_argument('username')).all():
            self.write("User exists")
            self.set_status(200)
            return

        u = User(self.get_argument('username'))
        u.setPass(self.get_argument('password'))
        self.db.add(u)
        session = Session(u)
        if not self.get_secure_cookie(COOKIE_NAME):
            self.set_secure_cookie(COOKIE_NAME, session.id)
        self.db.add(session)
        self.db.commit()
        self.write("OK")
        self.set_status(201)