Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add make_admin script #4853

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/docs/documentation/getting-started/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ docker exec -it mealie bash
python /app/mealie/scripts/reset_locked_users.py
```

## How can I reset admin privileges for my account?

If you've lost admin privileges and no other admin can restore them, you can use the Command Line Interface (CLI) to grant admin access.

```shell
docker exec -it mealie bash

python /app/mealie/scripts/make_admin.py
```

## How can I change my password?

You can change your password by going to the user profile page and clicking the "Change Password" button. Alternatively you can use the following script to change your password via the CLI if you are locked out of your account.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/overrides/api.html

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions mealie/scripts/make_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys

from mealie.core import root_logger
from mealie.db.db_setup import session_context
from mealie.repos.repository_factory import AllRepositories


def main():
confirmed = input("Enter user email to assign this user admin privileges: ")

logger = root_logger.get_logger()

with session_context() as session:
repos = AllRepositories(session, group_id=None, household_id=None)

user = repos.users.get_one(confirmed, "email")
if not user:
logger.error("no user found")
sys.exit(1)

user.admin = True
repos.users.update(user.id, user)

logger.info("updated user %s to admin", user.username)
input("press enter to exit ")
sys.exit(0)


if __name__ == "__main__":
main()
Loading