You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :omniauthable
include DeviseTokenAuth::Concerns::User
...
end
with SIngle Table Inheritance models set up as
class Applicant < User; end
class Judge < User; end
class Admin < User; end
I want to use Single Table Inheritance because I intend to treat the main User model almost as an abstract class and have all accounts be either an Applicant, Judge, or Admin, where I can leverage polymorphism to define custom validations for each of the different types of accounts, etc. Yes, I've considered using a gem to take care of the roles, but since my roling is very primitive (always applicant, judge, or admin) and I would like to leverage inheritance, I thought a simple inheritance pattern was more fitting for the occasion.
Since all accounts will have a single sign-up and sign-in flow regardless of the type of account, I only mounted the devise routes for the superclass, rather than individually for each of the subclasses.
The problem arises when attempting to log on. The response body will come back properly, but the header will come back missing the uid, authentication-token, and client fields.
Hello,
I have my user model set up as such
with SIngle Table Inheritance models set up as
and in my
config/routes.rb
I want to use Single Table Inheritance because I intend to treat the main
User
model almost as an abstract class and have all accounts be either anApplicant
,Judge
, orAdmin
, where I can leverage polymorphism to define custom validations for each of the different types of accounts, etc. Yes, I've considered using a gem to take care of the roles, but since my roling is very primitive (always applicant, judge, or admin) and I would like to leverage inheritance, I thought a simple inheritance pattern was more fitting for the occasion.Since all accounts will have a single sign-up and sign-in flow regardless of the type of account, I only mounted the devise routes for the superclass, rather than individually for each of the subclasses.
The problem arises when attempting to log on. The response body will come back properly, but the header will come back missing the
uid
,authentication-token
, andclient
fields.Stepping through the code in this gem, I believe the problem to be on this line:
https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/concerns/set_user_by_token.rb#L50
By changing the line from
to
I was able to get my Single Table Inheritance user models to log in properly and respond with the correct headers.
My questions are:
devise_token_auth
or the mounting of relevant routes that I could change to achieve this behavior?Thank you for your help.
The text was updated successfully, but these errors were encountered: