Sha256: c818274fb0f831710b7ec55ca98b434bde610b0d3978503c3c81bc1ce5619d18
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module OneSignalUser extend ActiveSupport::Concern included do before_action :set_onesignal_user helper_method :current_onesignal end def current_onesignal current_onesignal = {} current_onesignal[:id] = cookies[:oneSignalUserId] current_onesignal[:permission] = cookies[:oneSignalUserPermission] current_onesignal[OneSignalUser::Configuration.devise_class.downcase.to_sym] = OneSignalUser::Configuration.devise_class.constantize&.find_by(onesignal_id: current_onesignal[:id]) if cookies.has_key?(:oneSignalUserId) current_onesignal end private def set_onesignal_user if current_user onesignal_user_id = cookies[:oneSignalUserId] if onesignal_user_id.nil? current_user.update_attributes onesignal_id: nil, onesignal_permission: nil else current_user.update_attributes onesignal_id: onesignal_user_id, onesignal_permission: cookies[:oneSignalUserPermission] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devise-onesignal-1.0.1 | app/controllers/concerns/one_signal_user.rb |