Exemplo n.º 1
0
    def post(self):
        action = self.get_argument('action')
        message = None

        if action != 'add_user':
            raise HTTPError(400, 'Unknown action')

        add_user_form = AddUserForm(self.request.arguments)

        if add_user_form.validate():
            username = add_user_form.username.data
            password = add_user_form.password.data

            try:
                User.save_new_user(username, password)
            except IntegrityError:
                message = 'User already exists.'
            else:
                logger.info(self.user_audit_text('Added new user %s'),
                            username)
                self.redirect(self.reverse_url('user.overview', username))
                return

        self.render(
            'admin/account/all.html',
            add_user_form=add_user_form,
            usernames=User.all_usernames(),
            message=message
        )
Exemplo n.º 2
0
    def post(self):
        action = self.get_argument("action")
        message = None

        if action != "add_user":
            raise HTTPError(400, "Unknown action")

        add_user_form = AddUserForm(self.request.arguments)

        if add_user_form.validate():
            username = add_user_form.username.data
            password = add_user_form.password.data

            try:
                User.save_new_user(username, password)
            except IntegrityError:
                message = "User already exists."
            else:
                logger.info("Added new user %s", username)
                self.redirect(self.reverse_url("user.overview", username))
                return

        self.render(
            "admin/account/all.html", add_user_form=add_user_form, usernames=User.all_usernames(), message=message
        )
Exemplo n.º 3
0
    def get(self):
        add_user_form = AddUserForm()

        self.render(
            'admin/account/all.html',
            usernames=User.all_usernames(),
            add_user_form=add_user_form
        )