Commit 8efc0985

mo khan <mo@mokhan.ca>
2013-07-14 19:45:53
add route to logins controller
1 parent a399e90
Changed files (2)
app
controllers
config
app/controllers/api/v1/logins_controller.rb
@@ -0,0 +1,14 @@
+module Api
+  module V1
+    class LoginsController < ApplicationController
+      def create
+        @user = User.find_by_email(params[:email])
+        if @user.valid_password?(params[:password])
+          render json: { auth_token: @user.authentication_token }
+        else
+          render json: { auth_token: "" }
+        end
+      end
+    end
+  end
+end
config/routes.rb
@@ -60,7 +60,8 @@ Cake::Application.routes.draw do
 
   namespace :api, :defaults => { :format => 'json' }  do
     namespace :v1 do
-      resources :creations
+      resources :creations, :only => [:index]
+      resources :logins, :only => [:create]
     end
   end
 end