Skip to content

Commit

Permalink
Fix: Fix external login
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Apr 5, 2024
1 parent 132678a commit 9022a1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/app/controllers/api/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def callback
return
end

user = User.from_profile(params[:userProfile])
user = User.sync_profile(params[:userProfile])
uuid = params[:uuid]
$redis.with do |conn|
conn.set("sonolus_login/#{uuid}", user.id, ex: 30.minutes)
Expand Down
16 changes: 8 additions & 8 deletions backend/app/controllers/sonolus_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class SonolusController < ApplicationController
next
end
session_id = request.headers["Sonolus-Session"]
unless user_profile =
$redis
.with { |c| c.get("sonolus_session/#{session_id}") }
&.then { |json| JSON.parse(json, symbolize_names: true) }
logger.warn "Invalid session id: #{session_id}"
render json: { error: "Session expired" }, status: :unauthorized
next
end
begin
unless user_profile =
$redis
.with { |c| c.get("sonolus_session/#{session_id}") }
&.then { |json| JSON.parse(json, symbolize_names: true) }
logger.warn "Invalid session id: #{session_id}"
render json: { error: "Session expired" }, status: :unauthorized
next
end
user = User.find_by(handle: user_profile[:handle], owner_id: nil)

self.current_user = user
Expand Down

0 comments on commit 9022a1a

Please sign in to comment.