Refactor API user loading out to own method.
Refactor API user loading out to own method.

This simplifies the logic around what the current user is.

There is now an assumption that the current logged in user is user to
use permissions for.  The secondary user is the user whose API key is
specified.

If both an API key are specified, and a user is logged in, the logged in
user takes precedence.

Fixes #4440

project-eutopia/spree,sliaquat/spree,progsri/spree,richardnuno/solidus,zamiang/spree,AgilTec/spree,vinayvinsol/spree,kewaunited/spree,shekibobo/spree,ujai/spree,agient/agientstorefront,softr8/spree,dandanwei/spree,miyazawatomoka/spree,FadliKun/spree,Machpowersystems/spree_mach,quentinuys/spree,welitonfreitas/spree,madetech/spree,builtbybuffalo/spree,rakibulislam/spree,lyzxsc/spree,radarseesradar/spree,bonobos/solidus,softr8/spree,locomotivapro/spree,pulkit21/spree,derekluo/spree,dandanwei/spree,ayb/spree,carlesjove/spree,alejandromangione/spree,odk211/spree,tomash/spree,piousbox/spree,DarkoP/spree,raow/spree,jordan-brough/solidus,bricesanchez/spree,softr8/spree,Lostmyname/spree,tesserakt/clean_spree,DarkoP/spree,tancnle/spree,ramkumar-kr/spree,reinaris/spree,miyazawatomoka/spree,odk211/spree,rajeevriitm/spree,yiqing95/spree,Senjai/solidus,locomotivapro/spree,hoanghiep90/spree,surfdome/spree,radarseesradar/spree,kewaunited/spree,keatonrow/spree,alvinjean/spree,reinaris/spree,shekibobo/spree,azranel/spree,scottcrawford03/solidus,patdec/spree,jeffboulet/spree,Engeltj/spree,piousbox/spree,hoanghiep90/spree,KMikhaylovCTG/spree,volpejoaquin/spree,freerunningtech/spree,keatonrow/spree,yomishra/pce,pervino/solidus,ckk-scratch/solidus,ramkumar-kr/spree,robodisco/spree,firman/spree,jimblesm/spree,zamiang/spree,rajeevriitm/spree,freerunningtech/spree,dotandbo/spree,NerdsvilleCEO/spree,Machpowersystems/spree_mach,piousbox/spree,pervino/spree,firman/spree,caiqinghua/spree,DynamoMTL/spree,dafontaine/spree,cutefrank/spree,zaeznet/spree,edgward/spree,yiqing95/spree,project-eutopia/spree,caiqinghua/spree,shekibobo/spree,xuewenfei/solidus,nooysters/spree,assembledbrands/spree,xuewenfei/solidus,moneyspyder/spree,delphsoft/spree-store-ballchair,patdec/spree,hoanghiep90/spree,rajeevriitm/spree,alejandromangione/spree,adaddeo/spree,priyank-gupta/spree,beni55/spree,jordan-brough/spree,welitonfreitas/spree,JuandGirald/spree,nooysters/spree,ayb/spree,dafontaine/spree,devilcoders/solidus,azranel/spree,xuewenfei/solidus,zamiang/spree,miyazawatomoka/spree,watg/spree,firman/spree,alvinjean/spree,lsirivong/spree,xuewenfei/solidus,vcavallo/spree,abhishekjain16/spree,CiscoCloud/spree,ramkumar-kr/spree,priyank-gupta/spree,imella/spree,Arpsara/solidus,reidblomquist/spree,camelmasa/spree,ahmetabdi/spree,DynamoMTL/spree,StemboltHQ/spree,orenf/spree,jimblesm/spree,rbngzlv/spree,Senjai/solidus,vulk/spree,vinayvinsol/spree,carlesjove/spree,Kagetsuki/spree,lsirivong/spree,camelmasa/spree,caiqinghua/spree,azclick/spree,forkata/solidus,shaywood2/spree,pervino/solidus,bricesanchez/spree,devilcoders/solidus,pulkit21/spree,archSeer/spree,TrialGuides/spree,StemboltHQ/spree,forkata/solidus,TimurTarasenko/spree,builtbybuffalo/spree,jeffboulet/spree,njerrywerry/spree,tesserakt/clean_spree,watg/spree,Migweld/spree,APohio/spree,hifly/spree,piousbox/spree,ahmetabdi/spree,jsurdilla/solidus,karlitxo/spree,fahidnasir/spree,maybii/spree,radarseesradar/spree,lsirivong/spree,odk211/spree,berkes/spree,Boomkat/spree,athal7/solidus,sfcgeorge/spree,lsirivong/solidus,ujai/spree,edgward/spree,wolfieorama/spree,forkata/solidus,gregoryrikson/spree-sample,tancnle/spree,jeffboulet/spree,berkes/spree,TimurTarasenko/spree,locomotivapro/spree,richardnuno/solidus,zaeznet/spree,calvinl/spree,ramkumar-kr/spree,shaywood2/spree,FadliKun/spree,adaddeo/spree,fahidnasir/spree,mleglise/spree,shioyama/spree,grzlus/spree,patdec/spree,useiichi/spree,shaywood2/spree,Senjai/solidus,gregoryrikson/spree-sample,sunny2601/spree,alvinjean/spree,JDutil/spree,net2b/spree,Mayvenn/spree,yomishra/pce,PhoenixTeam/spree_phoenix,Hawaiideveloper/shoppingcart,Hawaiideveloper/shoppingcart,groundctrl/spree,jordan-brough/spree,reidblomquist/spree,camelmasa/spree,volpejoaquin/spree,pervino/solidus,bonobos/solidus,Kagetsuki/spree,moneyspyder/spree,trigrass2/spree,shioyama/spree,builtbybuffalo/spree,beni55/spree,wolfieorama/spree,maybii/spree,groundctrl/spree,bonobos/solidus,useiichi/spree,pervino/spree,yiqing95/spree,Ropeney/spree,JDutil/spree,SadTreeFriends/spree,CiscoCloud/spree,jimblesm/spree,kewaunited/spree,dafontaine/spree,vulk/spree,sliaquat/spree,shaywood2/spree,abhishekjain16/spree,sfcgeorge/spree,sunny2601/spree,jsurdilla/solidus,Ropeney/spree,scottcrawford03/solidus,gautamsawhney/spree,LBRapid/spree,Ropeney/spree,progsri/spree,project-eutopia/spree,imella/spree,surfdome/spree,vmatekole/spree,agient/agientstorefront,jordan-brough/spree,mindvolt/spree,jordan-brough/solidus,JDutil/spree,calvinl/spree,Arpsara/solidus,forkata/solidus,jparr/spree,grzlus/solidus,brchristian/spree,mleglise/spree,pervino/spree,miyazawatomoka/spree,Engeltj/spree,vcavallo/spree,grzlus/spree,keatonrow/spree,calvinl/spree,dotandbo/spree,FadliKun/spree,jspizziri/spree,siddharth28/spree,lyzxsc/spree,RatioClothing/spree,JuandGirald/spree,ckk-scratch/solidus,jasonfb/spree,Mayvenn/spree,Kagetsuki/spree,dafontaine/spree,delphsoft/spree-store-ballchair,orenf/spree,maybii/spree,jaspreet21anand/spree,gautamsawhney/spree,agient/agientstorefront,shekibobo/spree,rbngzlv/spree,wolfieorama/spree,vinsol/spree,joanblake/spree,jimblesm/spree,woboinc/spree,CiscoCloud/spree,grzlus/solidus,net2b/spree,scottcrawford03/solidus,bonobos/solidus,grzlus/spree,jparr/spree,caiqinghua/spree,brchristian/spree,vmatekole/spree,KMikhaylovCTG/spree,CJMrozek/spree,TimurTarasenko/spree,scottcrawford03/solidus,trigrass2/spree,firman/spree,alejandromangione/spree,robodisco/spree,SadTreeFriends/spree,sfcgeorge/spree,njerrywerry/spree,SadTreeFriends/spree,yushine/spree,CJMrozek/spree,lsirivong/spree,Arpsara/solidus,vinsol/spree,pervino/solidus,PhoenixTeam/spree_phoenix,rakibulislam/spree,rbngzlv/spree,SadTreeFriends/spree,yushine/spree,yushine/spree,ayb/spree,carlesjove/spree,sfcgeorge/spree,azranel/spree,tesserakt/clean_spree,athal7/solidus,mindvolt/spree,mleglise/spree,beni55/spree,jasonfb/spree,jordan-brough/solidus,omarsar/spree,joanblake/spree,jparr/spree,pulkit21/spree,jasonfb/spree,zaeznet/spree,Boomkat/spree,NerdsvilleCEO/spree,agient/agientstorefront,jspizziri/spree,raow/spree,hifly/spree,tailic/spree,JuandGirald/spree,radarseesradar/spree,omarsar/spree,abhishekjain16/spree,azclick/spree,robodisco/spree,KMikhaylovCTG/spree,hoanghiep90/spree,archSeer/spree,tesserakt/clean_spree,siddharth28/spree,gautamsawhney/spree,LBRapid/spree,zaeznet/spree,Hawaiideveloper/shoppingcart,thogg4/spree,hifly/spree,azclick/spree,jsurdilla/solidus,CJMrozek/spree,cutefrank/spree,zamiang/spree,CiscoCloud/spree,derekluo/spree,degica/spree,Ropeney/spree,thogg4/spree,jparr/spree,JuandGirald/spree,Engeltj/spree,berkes/spree,brchristian/spree,quentinuys/spree,yiqing95/spree,Migweld/spree,useiichi/spree,APohio/spree,athal7/solidus,shioyama/spree,robodisco/spree,karlitxo/spree,abhishekjain16/spree,karlitxo/spree,reidblomquist/spree,APohio/spree,jordan-brough/solidus,orenf/spree,freerunningtech/spree,grzlus/spree,woboinc/spree,reinaris/spree,welitonfreitas/spree,vmatekole/spree,net2b/spree,omarsar/spree,vinayvinsol/spree,jaspreet21anand/spree,yomishra/pce,bricesanchez/spree,TimurTarasenko/spree,Mayvenn/spree,watg/spree,welitonfreitas/spree,pervino/spree,cutefrank/spree,jspizziri/spree,richardnuno/solidus,rakibulislam/spree,lyzxsc/spree,Senjai/solidus,rakibulislam/spree,pulkit21/spree,AgilTec/spree,vcavallo/spree,odk211/spree,edgward/spree,PhoenixTeam/spree_phoenix,Lostmyname/spree,DarkoP/spree,TrialGuides/spree,sunny2601/spree,AgilTec/spree,Mayvenn/spree,sliaquat/spree,Kagetsuki/spree,maybii/spree,madetech/spree,devilcoders/solidus,dandanwei/spree,groundctrl/spree,azranel/spree,ckk-scratch/solidus,CJMrozek/spree,adaddeo/spree,gregoryrikson/spree-sample,surfdome/spree,mindvolt/spree,RatioClothing/spree,lsirivong/solidus,derekluo/spree,sideci-sample/sideci-sample-spree,dandanwei/spree,brchristian/spree,trigrass2/spree,madetech/spree,sunny2601/spree,hifly/spree,derekluo/spree,carlesjove/spree,project-eutopia/spree,ujai/spree,raow/spree,ayb/spree,kewaunited/spree,Migweld/spree,raow/spree,AgilTec/spree,cutefrank/spree,joanblake/spree,vmatekole/spree,vinsol/spree,jsurdilla/solidus,degica/spree,Hawaiideveloper/shoppingcart,KMikhaylovCTG/spree,devilcoders/solidus,orenf/spree,DynamoMTL/spree,woboinc/spree,jasonfb/spree,edgward/spree,gautamsawhney/spree,lsirivong/solidus,jaspreet21anand/spree,mleglise/spree,athal7/solidus,DarkoP/spree,builtbybuffalo/spree,Lostmyname/spree,tancnle/spree,vinayvinsol/spree,beni55/spree,alvinjean/spree,richardnuno/solidus,sideci-sample/sideci-sample-spree,Boomkat/spree,gregoryrikson/spree-sample,karlitxo/spree,dotandbo/spree,njerrywerry/spree,NerdsvilleCEO/spree,Boomkat/spree,lsirivong/solidus,vulk/spree,wolfieorama/spree,yushine/spree,TrialGuides/spree,assembledbrands/spree,jeffboulet/spree,groundctrl/spree,trigrass2/spree,moneyspyder/spree,berkes/spree,rajeevriitm/spree,delphsoft/spree-store-ballchair,joanblake/spree,patdec/spree,sliaquat/spree,vinsol/spree,thogg4/spree,PhoenixTeam/spree_phoenix,TrialGuides/spree,azclick/spree,fahidnasir/spree,mindvolt/spree,alejandromangione/spree,degica/spree,priyank-gupta/spree,moneyspyder/spree,assembledbrands/spree,calvinl/spree,DynamoMTL/spree,sideci-sample/sideci-sample-spree,priyank-gupta/spree,imella/spree,quentinuys/spree,tomash/spree,keatonrow/spree,nooysters/spree,omarsar/spree,Engeltj/spree,vulk/spree,adaddeo/spree,fahidnasir/spree,vcavallo/spree,APohio/spree,reinaris/spree,lyzxsc/spree,Lostmyname/spree,archSeer/spree,tomash/spree,progsri/spree,ckk-scratch/solidus,tailic/spree,thogg4/spree,Machpowersystems/spree_mach,grzlus/solidus,siddharth28/spree,surfdome/spree,locomotivapro/spree,progsri/spree,net2b/spree,tailic/spree,Arpsara/solidus,RatioClothing/spree,quentinuys/spree,reidblomquist/spree,ahmetabdi/spree,ahmetabdi/spree,jspizziri/spree,siddharth28/spree,jaspreet21anand/spree,tomash/spree,LBRapid/spree,softr8/spree,StemboltHQ/spree,njerrywerry/spree,volpejoaquin/spree,Migweld/spree,madetech/spree,JDutil/spree,volpejoaquin/spree,FadliKun/spree,delphsoft/spree-store-ballchair,grzlus/solidus,camelmasa/spree,dotandbo/spree,NerdsvilleCEO/spree,rbngzlv/spree,archSeer/spree,useiichi/spree,nooysters/spree,tancnle/spree