Commit 8efc0985
Changed files (2)
app
controllers
api
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