12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/shopify_cli/commands/switch.rb', line 12
def call(*)
if Shopifolk.acting_as_shopify_organization?
@ctx.puts(@ctx.message("core.switch.disabled_as_shopify_org"))
return
end
shop = if options.flags[:shop]
Login.validate_shop(options.flags[:shop], context: @ctx)
elsif (org_id = DB.get(:organization_id))
res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id)
res[:shop_domain]
else
AdminAPI.get_shop_or_abort(@ctx)
res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx)
res[:shop_domain]
end
DB.set(shop: shop)
IdentityAuth.new(ctx: @ctx).reauthenticate
@ctx.puts(@ctx.message("core.switch.success", shop))
end
|