From bee1ad0a93afe0cb7954c6558c1749314025c448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Mon, 5 Feb 2024 19:12:58 +0100 Subject: [PATCH] Fix account created by remote user header --- scripts/fix_user_db_for_local_users.sql | 3 +++ scripts/upgrade | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 scripts/fix_user_db_for_local_users.sql diff --git a/scripts/fix_user_db_for_local_users.sql b/scripts/fix_user_db_for_local_users.sql new file mode 100644 index 0000000..4873846 --- /dev/null +++ b/scripts/fix_user_db_for_local_users.sql @@ -0,0 +1,3 @@ +UPDATE `__APP__`.`user` +SET `login_type` = 2, `login_source` = 1, `login_name` = `name` +WHERE `user`.`name` in __USER_LIST__ ; diff --git a/scripts/upgrade b/scripts/upgrade index c0bc9e5..7719d42 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,6 +87,15 @@ if [[ -z "${jwt_secret:-}" ]]; then ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret" fi +#================================================= +# MIGRATION STEP Fix regression linked to 77c3678 and #76 +#================================================= + +list_param_sql=$(yunohost user list --output-as json | jq -c '.users | keys' | sed 's|\[|\(|' | sed 's|\]|\)|') +ynh_replace_string --match_string=__APP__ --replace_string="$app" --target_file=./fix_user_db_for_local_users.sql +ynh_replace_string --match_string=__USER_LIST__ --replace_string="$list_param_sql" --target_file=./fix_user_db_for_local_users.sql +ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./fix_user_db_for_local_users.sql + #================================================= # UPDATE A CONFIG FILE #=================================================