We've moved discussions to Discord

Log In not redirecting

Will King
I do not know why this is causing the login to not redirect, it is successful it seems, but it doesn't redirect:

This works:

def after_sign_in_path_for(resource_or_scope)
  stored_location_for(resource_or_scope) || user_root_url()
end

This causes the issue of not-redirecting:

def after_sign_in_path_for(resource_or_scope)
  stored_location_for(resource_or_scope) || user_root_url(subdomain: current_account.try(:subdomain))
end

I have validated that the subdomain exists, and it even shows in the logs:

Started POST "/users/sign_in" for 127.0.0.1 at 2021-03-06 14:12:46 -0600
Processing by Devise::SessionsController#create as TURBO_STREAM
  Parameters: {"authenticity_token"=>"8Y7WtHSc_CIfEjQDyfIcT9V5a-vDEwAlFhcbjNrWogfNIElJuVahIszWpOzr5uypucl7myYoM1UnzrbfEh83fg", "user"=>{"email"=>"[FILTERED]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log In"}
  User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["email", "hi@fabledlabs.com"], ["LIMIT", 1]]
  ↳ app/controllers/concerns/set_current_request_details.rb:15:in `set_request_details'
  Account Load (0.3ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."domain" = $1 LIMIT $2  [["domain", "lvh.me"], ["LIMIT", 1]]
  ↳ app/controllers/concerns/set_current_request_details.rb:27:in `account_from_domain'
  Account Load (0.2ms)  SELECT "accounts".* FROM "accounts" INNER JOIN "account_users" ON "accounts"."id" = "account_users"."account_id" WHERE "account_users"."user_id" = $1 AND "accounts"."id" IS NULL LIMIT $2  [["user_id", 2], ["LIMIT", 1]]
  ↳ app/controllers/concerns/set_current_request_details.rb:37:in `account_from_session'
  Account Load (0.3ms)  SELECT "accounts".* FROM "accounts" INNER JOIN "account_users" ON "accounts"."id" = "account_users"."account_id" WHERE "account_users"."user_id" = $1 ORDER BY "accounts"."created_at" ASC LIMIT $2  [["user_id", 2], ["LIMIT", 1]]
  ↳ app/controllers/concerns/set_current_request_details.rb:42:in `fallback_account'
logging#<Account id: 2, name: "FabledLabs", owner_id: 2, personal: false, domain: nil, subdomain: "fabledlabs", created_at: "2021-03-05 14:58:36.689158000 -0600", updated_at: "2021-03-05 14:58:36.689158000 -0600", processor: nil, processor_id: nil, trial_ends_at: nil, card_type: nil, card_last4: nil, card_exp_month: nil, card_exp_year: nil, extra_billing_info: nil, plan: nil, quantity: nil, card_token: nil>
Redirected to http://fabledlabs.lvh.me:3000/
Completed 302 Found in 158ms (ActiveRecord: 1.2ms | Allocations: 4700)

But it hangs here before moving on to a get request.
Donn Felker
I just tried this and when looking at the chrome developer tools I see a Content Security Policy Error. Do you see the same on your side?

Refused to connect to 'http://mysubdomain.lvh.me:3000/' because it violates the following Content Security Policy directive: "connect-src 'self' https: http://localhost:3035 ws://localhost:3035 ws://localhost:3000 ws://localhost:5000".
Chris Collinsworth
In your content_security_policy.rb uncomment:

 policy.connect_src :self, :https, "*.example"

This should get rid of your CSP errors.
Chris Oliver
Fetch requests cannot redirect between subdomains if I remember right. You'd have to disable Turbo on your sign in form to do that.

This is why we link directly to the subdomain in the navbar instead of redirects like we used to do.

https://fetch.spec.whatwg.org/#atomic-http-redirect-handling
Notifications
You’re not receiving notifications from this thread.