Sha256: b3f0bc8be885f10e159abcbec3a17a48ff84e761ece8558b41de8c0648d317ab
Contents?: true
Size: 1.7 KB
Versions: 4
Compression:
Stored size: 1.7 KB
Contents
module Eco module API module UseCases class DefaultCases class ChangeEMailCase < BaseCase def process @cases.define("change-email", type: :sync) do |entries, people, session, options| remove = session.job_group("main").new("remove account", type: :update, sets: :account) change = session.job_group("main").new("change email", type: :update, sets: :core) add_account = session.job_group("post").new("add account", type: :update, sets: :account) strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict)) entries.each.with_index do |entry, i| person = people.find(entry, strict: strict_search) if !person session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}") else unless entry.email.downcase == person.email account = person.account person.account = nil remove.add(person) new_email = entry.email change.add(person) do |person| person.sync person.email = new_email person end add_account.add(person) do |person| person.sync person.account = account person end end end end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems