@@ -42,14 +42,12 @@ function addOAuthControls(self)
4242
4343 function charImportStatus ()
4444 if not self .isAuthorized () and not self .oauthTimer then
45- local suffix = self .oauthErrCode and string.format (" : %s" , self .oauthErrCode ) or " "
46- return colorCodes .WARNING .. " Not authenticated" .. suffix
45+ return colorCodes .WARNING .. " Not authenticated"
4746 elseif not self .isAuthorized () and self .oauthTimer then
4847 local timeLeft = m_max (0 , (self .oauthTimer + 30 ) - os.time ())
4948 if timeLeft < 1 then
5049 self .oauthTimer = nil
51- local suffix = self .oauthErrCode and string.format (" : %s" , self .oauthErrCode ) or " "
52- return colorCodes .WARNING .. " Not authenticated" .. suffix
50+ return colorCodes .WARNING .. " Not authenticated"
5351 end
5452 return string.format (" Logging in... (%d)" , timeLeft ) .. (self .oauthErrCode or " " )
5553 -- user is spam changing realms and is rate limited
@@ -65,7 +63,6 @@ function addOAuthControls(self)
6563 elseif self .isAuthorized () then
6664 return " Authenticated"
6765 end
68- -- unreachable
6966 return " "
7067 end
7168
@@ -107,6 +104,7 @@ function addOAuthControls(self)
107104 self .rateLimitEndTime = timeNext
108105 -- token has been invalidated for some reason
109106 elseif err and err :match (" 401" ) then
107+ self .oauthErrCode = " Auth token is invalid. Please login again."
110108 main .api :ResetDetails ()
111109 else
112110 self .oauthErrCode = err
@@ -117,7 +115,6 @@ function addOAuthControls(self)
117115 main .api :DownloadCharacterList (realm .realmCode , onResponse )
118116 end
119117
120- -- OAuth Stage: Authenticate
121118 self .controls .authenticateButton = new (" ButtonControl" , { " TOPLEFT" , self .controls .characterImportAnchor , " TOPLEFT" },
122119 { 0 , 0 , 200 , 16 }, " ^7Authorize with Path of Exile" , function ()
123120 main .api :FetchAuthToken (function (errCode )
@@ -146,6 +143,13 @@ function addOAuthControls(self)
146143 return self .usingOauth and self .isAuthorized ()
147144 end
148145
146+ self .controls .oauthErrorLabel = new (" LabelControl" , { " TOPRIGHT" , self .controls .sectionOauthCharImport , " TOPRIGHT" },
147+ { - 8 , 40 , 0 , 18 })
148+ self .controls .oauthErrorLabel .label = function ()
149+ local text = self .oauthErrCode and string.format (" %sError: %s" , colorCodes .NEGATIVE , self .oauthErrCode ) or " "
150+ return text
151+ end
152+
149153 -- realm select
150154 function setLeaguesFromCharList ()
151155 local currentRealm = self .controls .accountRealm :GetSelValue ().realmCode
@@ -248,17 +252,24 @@ function addOAuthControls(self)
248252
249253 saveDetails (realm .id , league , selectedName )
250254 local deleteJewels = self .controls .charImportTreeClearJewels .state
255+ local function importHandler (data , errMsg )
256+ if data and data .character then
257+ self :ImportPassiveTreeAndJewels (data .character , deleteJewels )
258+ else
259+ if errMsg then
260+ self .oauthErrCode = " Could not import: " .. errMsg
261+ else
262+ self .oauthErrCode = " Could not import character"
263+ end
264+ end
265+ end
251266 if self .build .spec :CountAllocNodes () > 0 then
252267 main :OpenConfirmPopup (" Character Import" , " Importing the passive tree will overwrite your current tree." ,
253268 " Import" , function ()
254- main .api :DownloadCharacter (realm .realmCode , selectedName , function (char )
255- self :ImportPassiveTreeAndJewels (char .character , deleteJewels )
256- end )
269+ main .api :DownloadCharacter (realm .realmCode , selectedName , importHandler )
257270 end )
258271 else
259- main .api :DownloadCharacter (realm .realmCode , selectedName , function (char )
260- self :ImportPassiveTreeAndJewels (char .character , deleteJewels )
261- end )
272+ main .api :DownloadCharacter (realm .realmCode , selectedName , importHandler )
262273 end
263274 end )
264275 self .controls .charImportTree .enabled = function ()
@@ -274,11 +285,20 @@ function addOAuthControls(self)
274285
275286 saveDetails (realm .id , league , selectedName )
276287
277- main .api :DownloadCharacter (realm .realmCode , selectedName , function (char )
288+ main .api :DownloadCharacter (realm .realmCode , selectedName , function (data , errMsg )
278289 local clearItems = self .controls .charImportItemsClearItems .state
279290 local clearSkills = self .controls .charImportItemsClearSkills .state
280291 local ignoreWeaponSwap = self .controls .charImportItemsIgnoreWeaponSwap .state
281- self :ImportItemsAndSkills (char .character , clearItems , clearSkills , ignoreWeaponSwap )
292+ if data and data .character then
293+ self :ImportItemsAndSkills (data .character , clearItems , clearSkills , ignoreWeaponSwap )
294+ else
295+ if errMsg then
296+ self .oauthErrCode = " Could not import: " .. errMsg
297+ else
298+ self .oauthErrCode = " Could not import character"
299+ end
300+ end
301+
282302 end )
283303 end )
284304 self .controls .charImportItems .enabled = function ()
0 commit comments