Merge pull request #23095 from nextcloud/backport/23043/stable20
[stable20] Avoid crash when unauthenticated users make weather-related requests
This commit is contained in:
commit
6b8356ce35
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -46,7 +46,7 @@ class WeatherStatusController extends OCSController {
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
ILogger $logger,
|
ILogger $logger,
|
||||||
WeatherStatusService $service,
|
WeatherStatusService $service,
|
||||||
string $userId) {
|
?string $userId) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
|
@ -105,7 +105,7 @@ class WeatherStatusService {
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IAppManager $appManager,
|
IAppManager $appManager,
|
||||||
ICacheFactory $cacheFactory,
|
ICacheFactory $cacheFactory,
|
||||||
string $userId) {
|
?string $userId) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
|
|
@ -240,7 +240,11 @@ export default {
|
||||||
console.info('The weather status request was cancelled because the user navigates.')
|
console.info('The weather status request was cancelled because the user navigates.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showError(t('weather_status', 'There was an error getting the weather status information.'))
|
if (err.response && err.response.status === 401) {
|
||||||
|
showError(t('weather_status', 'You are not logged in.'))
|
||||||
|
} else {
|
||||||
|
showError(t('weather_status', 'There was an error getting the weather status information.'))
|
||||||
|
}
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -309,8 +313,11 @@ export default {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError(t('weather_status', 'There was an error setting the location address.'))
|
if (err.response && err.response.status === 401) {
|
||||||
console.debug(err)
|
showError(t('weather_status', 'You are not logged in.'))
|
||||||
|
} else {
|
||||||
|
showError(t('weather_status', 'There was an error setting the location address.'))
|
||||||
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -320,7 +327,11 @@ export default {
|
||||||
this.address = loc.address
|
this.address = loc.address
|
||||||
this.startLoop()
|
this.startLoop()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError(t('weather_status', 'There was an error setting the location.'))
|
if (err.response && err.response.status === 401) {
|
||||||
|
showError(t('weather_status', 'You are not logged in.'))
|
||||||
|
} else {
|
||||||
|
showError(t('weather_status', 'There was an error setting the location.'))
|
||||||
|
}
|
||||||
console.debug(err)
|
console.debug(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -328,7 +339,11 @@ export default {
|
||||||
try {
|
try {
|
||||||
await network.setMode(mode)
|
await network.setMode(mode)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError(t('weather_status', 'There was an error saving the mode.'))
|
if (err.response && err.response.status === 401) {
|
||||||
|
showError(t('weather_status', 'You are not logged in.'))
|
||||||
|
} else {
|
||||||
|
showError(t('weather_status', 'There was an error saving the mode.'))
|
||||||
|
}
|
||||||
console.debug(err)
|
console.debug(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -345,7 +360,11 @@ export default {
|
||||||
this.mode = MODE_MANUAL_LOCATION
|
this.mode = MODE_MANUAL_LOCATION
|
||||||
this.startLoop()
|
this.startLoop()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError(t('weather_status', 'There was an error using personal address.'))
|
if (err.response && err.response.status === 401) {
|
||||||
|
showError(t('weather_status', 'You are not logged in.'))
|
||||||
|
} else {
|
||||||
|
showError(t('weather_status', 'There was an error using personal address.'))
|
||||||
|
}
|
||||||
console.debug(err)
|
console.debug(err)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue