funkwhale/docs/administrator_documentation/manage_script/users.md

346 wiersze
5.7 KiB
Markdown
Czysty Zwykły widok Historia

2022-07-01 09:02:29 +00:00
# Manage users with manage.py
The {file}`manage.py` script includes commands for user management. Use these commands to automate managing users from the command line.
All users-related commands are available under the `python manage.py fw users` namespace.
## Create users
You can create users with the {file}`manage.py` script. There are different ways to create users depending on what approach you want to take.
### Create a user interactively
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users create
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users create
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Create a user with a random password
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users create --username <username> --email <user email> -p ""
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users create --username <username> --email <user email> -p ""
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Create a user with a password set from an environment variable
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
export FUNKWHALE_CLI_USER_PASSWORD=<password>
poetry run python manage.py fw users create --username <username> --email <user email>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
export FUNKWHALE_CLI_USER_PASSWORD=<password>
docker-compose run --rm api python manage.py fw users create --username <username> --email <user email>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
There are extra options for user configuration, such as quota and {term}`permissions`. Check the command help for more options.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users --help
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users --help
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
## Update users
You can update user accounts using the {file}`manage.py` script. Update commands are available under the `python manage.py fw users set` namespace.
### Set upload quota for a user
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --upload-quota 500 <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --upload-quota 500 <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Make users staff members
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --staff --superuser <user 1> <user 2>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --staff --superuser <user 1> <user 2>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Remove a user's staff privileges
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --no-staff --no-superuser <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --no-staff --no-superuser <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Give a user moderation permissions
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --permission-moderation <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --permission-moderation <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Reset a user's password
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --password "<password>" <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --password "<password>" <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Reset a user's password using an environment variable
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
export FUNKWHALE_CLI_USER_UPDATE_PASSWORD=<password>
poetry run python manage.py fw users set <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
export FUNKWHALE_CLI_USER_UPDATE_PASSWORD=<password>
docker-compose run --rm api python manage.py fw users set <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
There are extra options for updating users. Check the command help for more options.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users set --help
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users set --help
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
## Delete users
### Delete a user's account but leave a reference to them in the database
This prevents the same username being used in future.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} py
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users rm <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} py
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users rm <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
### Delete a user's account, including all references in the database
This means the username can be reused.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} py
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users rm --hard <user>
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} py
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users rm --hard <user>
```
2022-07-23 13:32:35 +00:00
:::
::::
2022-07-01 09:02:29 +00:00
There are extra options for deleting users. Check the command help for more options.
2022-07-23 13:32:35 +00:00
::::{tab-set}
:::{tab-item} Debian
:sync: debian
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
poetry run python manage.py fw users rm --help
```
2022-07-23 13:32:35 +00:00
:::
2022-07-01 09:02:29 +00:00
2022-07-23 13:32:35 +00:00
:::{tab-item} Docker
:sync: docker
2022-07-01 09:02:29 +00:00
2022-10-26 20:19:16 +00:00
```{code-block} sh
2022-07-01 09:02:29 +00:00
docker-compose run --rm api python manage.py fw users rm --help
```
2022-07-23 13:32:35 +00:00
:::
::::