mercredi 4 novembre 2015

How to make Rails API with Devise

I make an api in ruby on rails

module Api
class UserController < ApplicationController
    Swagger::Docs::Generator::set_real_methods
    skip_before_filter :verify_authenticity_token

    swagger_controller :users, "Users"
    swagger_api :create do
        summary "Creates a new User"
        param :form, :name, :string, :required, "Name"
        response :unauthorized
        response :not_acceptable
    end
    swagger_api :index do
        summary "List of all users"
    end



    def index
        @posts = User.all
        render json: @posts, status: :ok
    end

    def create  
        @user = User.new(user_params)
        if @user.save
            render json: {message: "success"},status: 401
        end
    end

I want to use devise for authentication but I doesn't understand how to integrate devise with api. Either I read a controller which inherit from Devise Controller?

Aucun commentaire:

Enregistrer un commentaire