Refactor token generation code using ActiveSupport::Concern