2
votes

I'm trying to override devise by placing controller in a namespaced route ("API") and i need to use the token authenticatable functionnality. i have 2 questions,

First, how can set by default devise to understand the params[:user] along params[:api_user]. Currently i could just send params in an array with :api_user key. if i try to do it with :user, devise don't recognize params, which seems logic.

Secondly, when i override the sessionsController like :

class Api::SessionsController < ::Devise::SessionsController    
     def create
         super
     end
end

how can i get back a reference to the created session or user, to give me the ability to manipulate the token authenticatable created.

I've already searched in a lot of topics about devise customisation, and found similar problems , but not really this one.

Thanks for your help

1

1 Answers

3
votes

About your first question you can use something like this

  namespace :api, :defaults => { :format => 'json' } do
    devise_for :users, :singular => "user", :controllers => { 
      :sessions => 'devise/sessions',
      :registrations => 'devise/registrations'
    }
  end