From 086a7cb862f5ff4d9c1f1e7d373be22ca85db80e Mon Sep 17 00:00:00 2001 From: junv Date: Wed, 19 Aug 2015 23:41:59 +0800 Subject: [PATCH] make sign up works --- app/controllers/api/v1/registrations_controller.rb | 5 +++-- app/models/user.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/v1/registrations_controller.rb b/app/controllers/api/v1/registrations_controller.rb index 7bb3bfc..df215f1 100644 --- a/app/controllers/api/v1/registrations_controller.rb +++ b/app/controllers/api/v1/registrations_controller.rb @@ -1,5 +1,6 @@ -class Api::V1::RegistrationsController < ApplicationController - skip_before_action :verify_authenticity_token +class Api::V1::RegistrationsController < Api::V1::ApplicationController + skip_before_action :authenticate_user_from_token + respond_to :json def create diff --git a/app/models/user.rb b/app/models/user.rb index 717e493..1521fde 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,6 +21,13 @@ class User < ActiveRecord::Base User.where(id: user_ids) end + def active_auth_token + if auth_tokens.empty? + generate_auth_key + end + auth_tokens.first.value + end + private def set_name @@ -38,13 +45,6 @@ class User < ActiveRecord::Base AuthToken.generate_token_for self end - def active_auth_token - if auth_tokens.empty? - generate_auth_key - end - auth_tokens.first.value - end - end