Sha256: d6b1f0345bc6d5dc33915123071c00d77dd47aa841f7d05e5c2afd11b34c20fa

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

module FwtPushNotificationServer
  
  class DeviceTokensController < FwtPushNotificationServer.api_controller_class

    skip_authorization_check

    def create
      @device_token = DeviceToken.find_or_create_by_token(params[:token])
      @device_token.update_attributes({
        :user_id => params[:user_id],
        :provider => params[:provider]
      })

      user = @device_token.user
      user.update_attributes(user_info_params) if user_info_params

      if @device_token.save
        render :json => { :status => 0 }
      else
        render :json => { :errors => @device_token.errors.full_messages }
      end
    end

    private
      def device_token_params
        params.permit(:token, :user_id, :provider)
      end

      def user_info_params
        params[:user].permit(FwtPushNotificationServer.permitted_user_attributes)
      end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fwt_push_notification_server-0.1.0.b1 app/controllers/fwt_push_notification_server/device_tokens_controller.rb