Sha256: 081e1d9fc8f584736df4ed8efafe80bd3e866dd419d31b4a44db9bcdab9d55a3

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

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) unless user_info_params.nil? && user.nil?

      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
        unless params[:user].nil? || FwtPushNotificationServer.permitted_user_attributes.nil?
          params[:user].permit(FwtPushNotificationServer.permitted_user_attributes)
        else
          nil
        end
      end

  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fwt_push_notification_server-0.1.0.b11 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b10 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b9 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b8 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b7 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b6 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b5 app/controllers/fwt_push_notification_server/device_tokens_controller.rb
fwt_push_notification_server-0.1.0.b4 app/controllers/fwt_push_notification_server/device_tokens_controller.rb