Skip to content

Commit

Permalink
feat: add make_admin script (#4853)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuchenpirat authored Jan 7, 2025
1 parent 688d07a commit 22f306a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
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()

0 comments on commit 22f306a

Please sign in to comment.