Skip to content

Commit

Permalink
feat: Add org role/permission helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
agis committed Nov 21, 2023
1 parent f4092d6 commit 24b085d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/clerk/authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ def clerk_organization_id
request.env["clerk"].org_id
end

def clerk_organization_role
request.env["clerk"].org_role
end

def clerk_organization_permissions
request.env["clerk"].org_permissions
end

def clerk_user_signed_in?
!!clerk_verified_session_claims
end
Expand All @@ -82,7 +90,8 @@ def clerk_user_profile_url
:clerk_verified_session_claims, :clerk_verified_session_token,
:clerk_user, :clerk_user_id, :clerk_user_signed_in?, :clerk_sign_in_url,
:clerk_sign_up_url, :clerk_user_profile_url,
:clerk_organization, :clerk_organization_id
:clerk_organization, :clerk_organization_id, :clerk_organization_role,
:clerk_organization_permissions
end
end
end
12 changes: 12 additions & 0 deletions lib/clerk/rack_middleware_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ def org_id
@session_claims["org_id"]
end

def org_role
return nil if @session_claims.nil?

@session_claims["org_role"]
end

def org_permissions
return nil if @session_claims.nil?

@session_claims["org_permissions"]
end

private

def fetch_user(user_id)
Expand Down

0 comments on commit 24b085d

Please sign in to comment.