Sha256: 8e6c968977f65171e73471f4c02673d3581565f1deed53827221375932a2f516

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

module Arcadex
	module Destroy

		#Arcadex.destroy_token(token.auth_token)
		def self.destroy_auth_token(auth_token)
			token = ::Arcadex::Find.find_token_by_auth_token(auth_token)
			::Arcadex::Destroy.destroy_token(token)
		end
		def self.destroy_token(token)
			if token.nil?
				return nil
			end
			token.destroy
		end
		#Arcadex.destroy_all_tokens(instance.id,instance.class.to_s)
		def self.destroy_all_tokens(id,type)
			if ::Object.const_get(type).exists?(id)
				instance = ::Object.const_get(type).find(id)
				instance.tokens.destroy_all
			end
		end
		#Arcadex.token_expired?(token)
		#How long should tokens last? A day if not rememberable
		#And a month if you are?
		def self.token_expired?(token)
			if !token.expiration_minutes.nil?
				date = token.created_at.utc + token.expiration_minutes.minutes
				if Time.now.utc > date
					return true
				else
					return false
				end
			else
				return false
			end
		end

	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arcadex-1.2.3 lib/arcadex/destroy.rb
arcadex-1.2.1 lib/arcadex/destroy.rb
arcadex-1.2.0 lib/arcadex/destroy.rb
arcadex-1.1.3 lib/arcadex/destroy.rb
arcadex-1.1.2 lib/arcadex/destroy.rb