app/models/landable/author.rb in landable-1.13.2 vs app/models/landable/author.rb in landable-1.14.0

- old
+ new

@@ -3,11 +3,25 @@ include Landable::TableName has_many :access_tokens def self.authenticate!(username, token_id) author = where(username: username).first - return unless author - return unless author.access_tokens.fresh.exists?(token_id) + return unless author && author.access_tokens.fresh.exists?(token_id) author + end + + def can_read + token = access_tokens.fresh.last + token.present? && token.can_read? + end + + def can_edit + token = access_tokens.fresh.last + token.present? && token.can_edit? + end + + def can_publish + token = access_tokens.fresh.last + token.present? && token.can_publish? end end end