From c85903383a2a9846538d41c1a9c4eff852789f71 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 8 Apr 2019 09:46:58 -0500 Subject: [PATCH] Fix to_json for storing user preferences --- src/invidious.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index a58749ac..06e96a53 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -956,7 +956,7 @@ post "/login" do |env| if env.request.cookies["PREFS"]? preferences = env.get("preferences").as(Preferences) - PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences, user.email) + PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences.to_json, user.email) cookie = env.request.cookies["PREFS"] cookie.expires = Time.new(1990, 1, 1) @@ -1129,8 +1129,8 @@ post "/login" do |env| end if env.request.cookies["PREFS"]? - preferences = env.get("preferences").as(Preferences).to_json - PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences, user.email) + preferences = env.get("preferences").as(Preferences) + PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences.to_json, user.email) cookie = env.request.cookies["PREFS"] cookie.expires = Time.new(1990, 1, 1)