add client side registration feature

This commit is contained in:
2014-03-11 17:55:25 +08:00
parent 4b3f006eb3
commit 35a135106e
8 changed files with 46 additions and 1 deletions
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
@@ -0,0 +1,17 @@
class Api::V1::RegistrationsController < ApplicationController
before_filter :allow_cors
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.auth_keys.last.value, :email=>user.email), :status=>201
return
else
warden.custom_failure!
render :json=> user.errors, :status=>422
end
end
end
@@ -12,7 +12,6 @@ class Api::V1::SessionsController < Devise::SessionsController
token: current_user.auth_keys.last.value,
avatar: current_user.avatar,
name: current_user.preferred_name ? current_user.preferred_name : '匿名'
}
}
@@ -0,0 +1,2 @@
module Api::V1::RegistrationsHelper
end
+1
View File
@@ -50,6 +50,7 @@ Libr::Application.routes.draw do
namespace :v1 do
devise_scope :user do
resources :sessions, :only => [:create, :destroy, :failure]
resources :registrations, :only => [:create]
end
get 'locations/detail' => 'locations#get_location'
@@ -0,0 +1,5 @@
require 'spec_helper'
describe Api::V1::RegistrationsController do
end
@@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the Api::V1::RegistrationsHelper. For example:
#
# describe Api::V1::RegistrationsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
describe Api::V1::RegistrationsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end