feat: add make_admin script (#4853)
This commit is contained in:
1 parent
688d07a5c8
commit
22f306a384
3 files changed
+41
-1
No files matched your search
@@ -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.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div id="redoc-container"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"> </script>
|
||||
<script>
|
||||
var spec = {"openapi": "3.1.0", "info": {"title": "Mealie", "description": "\nMealie is a web application for managing your recipes, meal plans, and shopping lists. This is the Restful\nAPI interactive documentation that can be used to explore the API. If you're justing getting started with\nthe API and want to get started quickly, you can use the\n[API Usage | Mealie Docs](https://docs.mealie.io/documentation/getting-started/api-usage/)\nas a reference for how to get started.\n\n\nIf you have any questions or comments about mealie, please use the discord server to talk to the developers or other\ncommunity members. If you'd like to file an issue, please use the\n[GitHub Issue Tracker | Mealie](https://github.com/mealie-recipes/mealie/issues/new/choose)\n\n\n## Helpful Links\n- [Home Page](https://mealie.io)\n- [Documentation](https://docs.mealie.io)\n- [Discord](https://discord.gg/QuStdQGSGK)\n- [Demo](https://demo.mealie.io)\n", "version": "develop"}, "paths": {"/api/app/about": {"get": {"tags": ["App: About"], "summary": "Get App Info", "description": "Get general application information", "operationId": "get_app_info_api_app_about_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppInfo"}}}}}}}, "/api/app/about/startup-info": {"get": {"tags": ["App: About"], "summary": "Get Startup Info", "description": "returns helpful startup information", "operationId": "get_startup_info_api_app_about_startup_info_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppStartupInfo"}}}}}}}, "/api/app/about/theme": {"get": {"tags": ["App: About"], "summary": "Get App Theme", "description": "Get's the current theme settings", "operationId": "get_app_theme_api_app_about_theme_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppTheme"}}}}}}}, "/api/auth/token": {"post": {"tags": ["Users: Authentication"], "summary": "Get Token", "operationId": "get_token_api_auth_token_post", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_get_token_api_auth_token_post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/auth/oauth": {"get": {"tags": ["Users: Authentication"], "summary": "Oauth Login", "operationId": "oauth_login_api_auth_oauth_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/api/auth/oauth/callback": {"get": {"tags": ["Users: Authentication"], "summary": "Oauth Callback", "operationId": "oauth_callback_api_auth_oauth_callback_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/api/auth/refresh": {"get": {"tags": ["Users: Authentication"], "summary": "Refresh Token", "description": "Use a valid token to get another token", "operationId": "refresh_token_api_auth_refresh_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"OAuth2PasswordBearer": []}]}}, "/api/auth/logout": {"post": {"tags": ["Users: Authentication"], "summary": "Logout", "operationId": "logout_api_auth_logout_post", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"OAuth2PasswordBearer": []}]}}, "/api/users/register": {"post": {"tags": ["Users: Registration"], "summary": "Register New User", "operationId": "register_new_user_api_users_register_post", "parameters": [{"name": "accept-language", "in": "header", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Accept-Language"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateUserRegistration"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserOut"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/users/self": {"get": {"tags": ["Users: CRUD"], "summary": "Get Logged In User", "operationId": "get_logged_in_user_api_users_self_get", "security": [{"OAuth2PasswordBearer": []}, {"OAuth2PasswordBearer": []}], "parameters": [{"name": "accept-language", "in": "header", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Accept-Language"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref"Line truncated
|
||||
var spec = {"openapi": "3.1.0", "info": {"title": "Mealie", "description": "\nMealie is a web application for managing your recipes, meal plans, and shopping lists. This is the Restful\nAPI interactive documentation that can be used to explore the API. If you're justing getting started with\nthe API and want to get started quickly, you can use the\n[API Usage | Mealie Docs](https://docs.mealie.io/documentation/getting-started/api-usage/)\nas a reference for how to get started.\n\n\nIf you have any questions or comments about mealie, please use the discord server to talk to the developers or other\ncommunity members. If you'd like to file an issue, please use the\n[GitHub Issue Tracker | Mealie](https://github.com/mealie-recipes/mealie/issues/new/choose)\n\n\n## Helpful Links\n- [Home Page](https://mealie.io)\n- [Documentation](https://docs.mealie.io)\n- [Discord](https://discord.gg/QuStdQGSGK)\n- [Demo](https://demo.mealie.io)\n", "version": "develop"}, "paths": {"/api/app/about": {"get": {"tags": ["App: About"], "summary": "Get App Info", "description": "Get general application information", "operationId": "get_app_info_api_app_about_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppInfo"}}}}}}}, "/api/app/about/startup-info": {"get": {"tags": ["App: About"], "summary": "Get Startup Info", "description": "returns helpful startup information", "operationId": "get_startup_info_api_app_about_startup_info_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppStartupInfo"}}}}}}}, "/api/app/about/theme": {"get": {"tags": ["App: About"], "summary": "Get App Theme", "description": "Get's the current theme settings", "operationId": "get_app_theme_api_app_about_theme_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppTheme"}}}}}}}, "/api/auth/token": {"post": {"tags": ["Users: Authentication"], "summary": "Get Token", "operationId": "get_token_api_auth_token_post", "requestBody": {"content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Body_get_token_api_auth_token_post"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/auth/oauth": {"get": {"tags": ["Users: Authentication"], "summary": "Oauth Login", "operationId": "oauth_login_api_auth_oauth_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/api/auth/oauth/callback": {"get": {"tags": ["Users: Authentication"], "summary": "Oauth Callback", "operationId": "oauth_callback_api_auth_oauth_callback_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/api/auth/refresh": {"get": {"tags": ["Users: Authentication"], "summary": "Refresh Token", "description": "Use a valid token to get another token", "operationId": "refresh_token_api_auth_refresh_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"OAuth2PasswordBearer": []}]}}, "/api/auth/logout": {"post": {"tags": ["Users: Authentication"], "summary": "Logout", "operationId": "logout_api_auth_logout_post", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"OAuth2PasswordBearer": []}]}}, "/api/users/register": {"post": {"tags": ["Users: Registration"], "summary": "Register New User", "operationId": "register_new_user_api_users_register_post", "parameters": [{"name": "accept-language", "in": "header", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Accept-Language"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateUserRegistration"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/UserOut"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/users/self": {"get": {"tags": ["Users: CRUD"], "summary": "Get Logged In User", "operationId": "get_logged_in_user_api_users_self_get", "security": [{"OAuth2PasswordBearer": []}, {"OAuth2PasswordBearer": []}], "parameters": [{"name": "accept-language", "in": "header", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Accept-Language"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref"Line truncated
|
||||
Redoc.init(spec, {}, document.getElementById("redoc-container"));
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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()
|
||||
Reference in new issue
Block a user