Huy
Huy

Reputation: 11206

How to sign a get request from a link_to button

I am using api_auth to sign my requests. I have a link_to button that makes a get request to a controller (allowing my admins to sign in as any users via Devise).

link_to "Click Here", "https://localhost:3000/sign_in_as_user?admin_user=#{current_user.id}&user_id=#{s.id}", target: "_blank"

I've read through the api_auth doc (https://github.com/mgomes/api_auth) and see how I can generate a signed request in controllers.

However, I want to be able to create a signed_request when I click on the above link_to tag.

How do I successfully sign a link_to get request?

Upvotes: 0

Views: 100

Answers (1)

Crooked Stud
Crooked Stud

Reputation: 19

You would need to create a helper method, or controller method that creates the signed request. Then you can link to the action that creates the signed request for you.

link_to "Click Here", {:action => :new_action_to_create_signed_request}, :method => :post

Upvotes: 1

Related Questions