mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 07:39:41 +02:00
feat: add make_admin script (#4853)
This commit is contained in:
parent
688d07a5c8
commit
22f306a384
3 changed files with 41 additions and 1 deletions
|
@ -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.
|
||||
|
|
File diff suppressed because one or more lines are too long
30
mealie/scripts/make_admin.py
Normal file
30
mealie/scripts/make_admin.py
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue