Note that there are some explanatory texts on larger screens.

plurals
  1. POcustom authentication with devise for an API
    primarykey
    data
    text
    <p>so i have a little tricky combination here</p> <pre><code>Company has many Users User belongs to Company </code></pre> <p>The User is managed for authentication with devise</p> <pre><code>class User &lt; ActiveRecord::Base belongs_to :company devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable </code></pre> <p>You can login as a User and create Objects that all belong to the Company of that, not to the user, for example: <code>Text</code>. (<code>company.texts</code>)</p> <p>now i created a simple API using the <code>acts_as_api</code> gem. for this i simply have to modify my text-controller, f.e. the show action.</p> <pre><code>class TextsController &lt; ApplicationController load_and_authorize_resource def show #@text = Text.find(params[:id]) respond_to do |format| format.html format.json { render_for_api :texts_all, :json =&gt; @text } end </code></pre> <p>this works quite fine on the website. the problem is the API. i don't want to authenticate when accessing the api via the user model. the company does have a attribute called <code>:hash</code>which i want to use for Auth in the API.</p> <p>i don't have any idea how to achieve this using devise (or any other method). so by default devise wants a user to be logged in because of <code>load_and_authorize_resource</code> in my controller which is fine for the html response but not for the json response.</p> <p>any ideas?</p> <p>thanks for reading this. please leave a comment if something is unclear!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload