From f1820ffaf7cc9fe423d67e5782db7d57b9c9085a Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 11 Feb 2019 20:47:26 -0600 Subject: [PATCH] Add fix for user array --- src/invidious.cr | 8 ++++---- src/invidious/users.cr | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 83e77016..c83d0a94 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -163,10 +163,10 @@ before_all do |env| # Invidious users only have SID if !env.request.cookies.has_key? "SSID" - email = PG_DB.query_one?("SELECT email FROM session_ids WHERE id = $1", sid, as: String) +email = PG_DB.query_one?("SELECT email FROM session_ids WHERE id = $1", sid, as: String) - if email - user = PG_DB.query_one("SELECT * FROM users WHERE email = $1", email, as: User) +if email + user = PG_DB.query_one("SELECT * FROM users WHERE email = $1", email, as: User) challenge, token = create_response(user.email, "sign_out", HMAC_KEY, PG_DB, 1.week) env.set "challenge", challenge @@ -1028,7 +1028,7 @@ post "/login" do |env| user, sid = create_user(sid, email, password) user_array = user.to_a - user_array[5] = user_array[5].to_json + user_array[4] = user_array[4].to_json args = arg_array(user_array) PG_DB.exec("INSERT INTO users VALUES (#{args})", user_array) diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 67125654..072638ba 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -132,7 +132,7 @@ def get_user(sid, headers, db, refresh = true) user, sid = fetch_user(sid, headers, db) user_array = user.to_a - user_array[5] = user_array[5].to_json + user_array[4] = user_array[4].to_json args = arg_array(user_array) db.exec("INSERT INTO users VALUES (#{args}) \ @@ -154,7 +154,7 @@ def get_user(sid, headers, db, refresh = true) user, sid = fetch_user(sid, headers, db) user_array = user.to_a - user_array[5] = user_array[5].to_json + user_array[4] = user_array[4].to_json args = arg_array(user.to_a) db.exec("INSERT INTO users VALUES (#{args}) \