Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Jul 28, 2023
1 parent 241ded5 commit fd3c540
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ The `Web UI` column is set to yes if an environment variable can alternatively b
| `TMDB_API_KEY` | - | **Required** (get key [here](https://www.themoviedb.org/settings/api)) | yes |
| `APPLICATION_URL` | - | Public base url of the application (e.g. `htttp://localhost`) | yes |
| `TMDB_ENABLE_IMAGE_CACHING` | `0` | More info [here](features/tmdb-data.md#image-cache) | |
| `PLEX_IDENTIFIER` | - | Required for Plex Authentication. Generate with e.g. `openssl rand -base64 32` | |
| `PLEX_APP_NAME` | `Movary` | Required for Plex Authentication | |
| `PLEX_IDENTIFIER` | - | Required for Plex authentication. Generate with e.g. `openssl rand -base64 32` | |
| `PLEX_APP_NAME` | `Movary` | Required for Plex authentication | |
| `ENABLE_REGISTRATION` | `0` | Enables public user registration | |
| `MIN_RUNTIME_IN_SECONDS_FOR_JOB_PROCESSING` | `15` | Minimum time between background jobs processing | |
| `TIMEZONE` | `Europe/Berlin` | Supported timezones [here](https://www.php.net/manual/en/timezones.php) | |
Expand Down
19 changes: 13 additions & 6 deletions src/HttpController/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,19 @@ public function renderPlexPage() : Response
return Response::createSeeOther('/');
}

$plexAccessToken = $this->userApi->findPlexAccessToken($this->authenticationService->getCurrentUserId());
$plexAccessToken = null;
$plexIdentifier = $this->serverSettings->getPlexIdentifier();

if ($plexAccessToken !== null && $this->serverSettings->getPlexIdentifier() !== null) {
$plexAccount = $this->plexApi->findPlexAccount($plexAccessToken);
if ($plexAccount !== null) {
$plexUsername = $plexAccount->getPlexUsername();
$plexServerUrl = $this->userApi->findPlexServerUrl($this->authenticationService->getCurrentUserId());
if ($plexIdentifier !== null) {
$plexAccessToken = $this->userApi->findPlexAccessToken($this->authenticationService->getCurrentUserId());

if ($plexAccessToken !== null) {
$plexAccount = $this->plexApi->findPlexAccount($plexAccessToken);

if ($plexAccount !== null) {
$plexUsername = $plexAccount->getPlexUsername();
$plexServerUrl = $this->userApi->findPlexServerUrl($this->authenticationService->getCurrentUserId());
}
}
}

Expand All @@ -378,6 +384,7 @@ public function renderPlexPage() : Response
'plexTokenExists' => $plexAccessToken !== null,
'plexServerUrl' => $plexServerUrl ?? '',
'plexUsername' => $plexUsername ?? '',
'hasServerPlexIdentifier' => $plexIdentifier !== null,
]),
);
}
Expand Down
7 changes: 6 additions & 1 deletion templates/page/settings-integration-plex.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@
style="margin-left: 5%;margin-right: 5%;margin-bottom: 1rem!important;">
Authentication disabled - {% if currentUserIsAdmin == true %}<a href="/settings/server/general">Application url</a>{% else %}Application url{% endif %} required
</div>
<div class="alert alert-warning {% if hasServerPlexIdentifier == true %}d-none{% endif %}"
role="alert"
style="margin-left: 5%;margin-right: 5%;margin-bottom: 1rem!important;">
Authentication disabled - Plex client identifier required
</div>
</div>

<div id="authenticateWithPlexDiv" class="{% if plexTokenExists == true %}d-none{% endif %}">
<button type="button" class="btn btn-primary mb-3" onclick="authenticateWithPlex()" {% if isActive == '' %}disabled{% endif %}>Authenticate</button>
<button type="button" class="btn btn-primary mb-3" onclick="authenticateWithPlex()" {% if (isActive == '') or (hasServerPlexIdentifier == false) %}disabled{% endif %}>Authenticate</button>
</div>
<div id="removeAuthenticationWithPlexDiv" class="{% if plexTokenExists == false %}d-none{% endif %}">
<button type="button" class="btn btn-danger mb-3" onclick="removePlexAuthentication()">Remove Authentication</button>
Expand Down

0 comments on commit fd3c540

Please sign in to comment.