Fix to_json for storing user preferences

This commit is contained in:
Omar Roth 2019-04-08 09:46:58 -05:00
parent 4aededf038
commit c85903383a
1 changed files with 3 additions and 3 deletions

View File

@ -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)