heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
24.01k stars 5.55k forks source link

Support for frontend frameworks? #5272

Open ughstudios opened 4 years ago

ughstudios commented 4 years ago

Will devise ever have support for any frontend frameworks such as emberjs, angular, react, or vue?

ughstudios commented 4 years ago

image For some reason I'm unable to login when using a request from the postman stuff here: https://github.com/heartcombo/devise/wiki/API-Mode-Compatibility-Guide

getaaron commented 4 years ago

@Bdoom guessing you aren't sending the Content-Type and Accept headers in the assumptions section

julienanne commented 3 years ago

@Bdoom, same issue for me (after using this two headers Content-Type and Accept), so i use this guide here : https://github.com/waiting-for-dev/devise-jwt/wiki/Configuring-devise-for-APIs#responding-to-json

Just the first step with the "respond_to :json" directive in the ApplicationController and enjoy ;)

Another tips if you don't want to set the Accept header, you can follow this part of guide https://github.com/waiting-for-dev/devise-jwt/wiki/Configuring-devise-for-APIs#defaulting-to-json-as-format

Finally if you don't want to keep all routes like the GET sessions#new route you can avoid that with :

  devise_for :users, skip: :sessions # or skip: :all
  devise_scope :user do
    post 'users/sign_in' => 'devise/sessions#create', defaults: { format: :json }, :as => 'sign_in_user_session'
    delete 'users/sign_out' => 'devise/sessions#destroy', defaults: { format: :json }, :as => 'sign_out_user_session'
  end

in your routes.rb file