Permalink
Browse files

Auth check at /auth.xml and /auth.json

  • Loading branch information...
Squeegy committed Jul 13, 2009
1 parent 1f791d2 commit c8fe9b514590fa956611874cdd9f33ae057e7caf
@@ -0,0 +1,12 @@
+class AuthController < ApplicationController
+ def create
+ @success = LoginCookie.new(params[:username], params[:password]).success?
+
+ if @success
+ render
+ else
+ render :status => :forbidden
+ end
+ end
+
+end
@@ -0,0 +1,2 @@
+module AuthHelper
+end
@@ -0,0 +1 @@
+<%= { :authentication => { :success => @success } }.to_json %>
@@ -0,0 +1,9 @@
+xml.authentication do
+ xml.success do
+ if @success
+ xml.true
+ else
+ xml.false
+ end
+ end
+end
View
@@ -40,6 +40,8 @@
map.resources :images, :only => [:create]
map.resource :devices, :only => [:create, :destroy]
+ map.auth 'auth.:format', :controller => 'auth', :action => 'create'
+
map.search 'search.:format', :controller => 'search'
map.push 'push', :controller => 'parse', :action => 'push'
View
@@ -137,6 +137,18 @@ <h2>GET /users/[username].fmt</h2>
<p>Returns public data for a single user.</p>
+ <a name="auth"></a>
+ <h1>Authentication Check</h1>
+
+ <h2>POST /auth.fmt</h2>
+ <p>Will return a "200 OK" if the provided credentials are valid, or a "403 Forbidden" if they are not. It requires that you send the following variables in the POST body:</p>
+
+ <ul>
+ <li><code>username</code></li>
+ <li><code>password</code></li>
+ </ul>
+
+
<a name="messages"></a>
<h1>Messages</h1>
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AuthControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class AuthHelperTest < ActionView::TestCase
+end

0 comments on commit c8fe9b5

Please sign in to comment.