From 0f36c7931fe04bb3d6a3fd70a25fe1090f48e774 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 8 Dec 2012 16:05:40 +0100 Subject: serve api version 1 in /1/ Just a very simple start for now. Do we want to use the api for the secure remote password auth from js? --- users/app/controllers/v1/sessions_controller.rb | 28 +++++++++++++++++++++++++ users/app/controllers/v1/users_controller.rb | 13 ++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 users/app/controllers/v1/sessions_controller.rb create mode 100644 users/app/controllers/v1/users_controller.rb (limited to 'users/app') diff --git a/users/app/controllers/v1/sessions_controller.rb b/users/app/controllers/v1/sessions_controller.rb new file mode 100644 index 0000000..5b4a13b --- /dev/null +++ b/users/app/controllers/v1/sessions_controller.rb @@ -0,0 +1,28 @@ +module V1 + class SessionsController < ApplicationController + + skip_before_filter :verify_authenticity_token + + def new + @session = Session.new + if authentication_errors + @errors = authentication_errors + render :status => 422 + end + end + + def create + authenticate! + end + + def update + authenticate! + render :json => session.delete(:handshake) + end + + def destroy + logout + redirect_to root_path + end + end +end diff --git a/users/app/controllers/v1/users_controller.rb b/users/app/controllers/v1/users_controller.rb new file mode 100644 index 0000000..eda2fad --- /dev/null +++ b/users/app/controllers/v1/users_controller.rb @@ -0,0 +1,13 @@ +module V1 + class UsersController < ApplicationController + + skip_before_filter :verify_authenticity_token, :only => [:create] + + respond_to :json + + def create + @user = User.create(params[:user]) + respond_with @user + end + end +end -- cgit v1.2.3 From 1a26988cb7ff30061473f4a781166b184b3037ce Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 10 Dec 2012 15:39:02 +0100 Subject: use consistent naming scheme across CA, webapp and couchDB install --- users/app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'users/app') diff --git a/users/app/models/user.rb b/users/app/models/user.rb index ae271ce..340ad9c 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -1,5 +1,7 @@ class User < CouchRest::Model::Base + use_database :users + property :login, String, :accessible => true property :email, String, :accessible => true property :email_forward, String, :accessible => true -- cgit v1.2.3