Compare commits
2 Commits
test-ip-fo
...
test-fix-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
166796804e | ||
|
|
9aeb3604e6 |
@@ -133,6 +133,11 @@ class JellyfinAPI extends ExternalAPI {
|
|||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
logger.debug(`Logging in to Jellyfin server: ${this.jellyfinHost}`, {
|
||||||
|
label: 'Jellyfin API',
|
||||||
|
clientIp: ClientIP,
|
||||||
|
});
|
||||||
|
|
||||||
const authResponse = await this.post<JellyfinLoginResponse>(
|
const authResponse = await this.post<JellyfinLoginResponse>(
|
||||||
'/Users/AuthenticateByName',
|
'/Users/AuthenticateByName',
|
||||||
{
|
{
|
||||||
@@ -146,6 +151,12 @@ class JellyfinAPI extends ExternalAPI {
|
|||||||
|
|
||||||
return authResponse;
|
return authResponse;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logger.error('Failed to login to Jellyfin server', {
|
||||||
|
label: 'Jellyfin API',
|
||||||
|
clientIp: ClientIP,
|
||||||
|
error: e,
|
||||||
|
});
|
||||||
|
|
||||||
const status = e.response?.status;
|
const status = e.response?.status;
|
||||||
|
|
||||||
const networkErrorCodes = new Set([
|
const networkErrorCodes = new Set([
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { ApiError } from '@server/types/error';
|
|||||||
import * as EmailValidator from 'email-validator';
|
import * as EmailValidator from 'email-validator';
|
||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import gravatarUrl from 'gravatar-url';
|
import gravatarUrl from 'gravatar-url';
|
||||||
|
import net from 'net';
|
||||||
|
|
||||||
const authRoutes = Router();
|
const authRoutes = Router();
|
||||||
|
|
||||||
@@ -271,11 +272,21 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
|
|||||||
? jellyfinHost.slice(0, -1)
|
? jellyfinHost.slice(0, -1)
|
||||||
: jellyfinHost;
|
: jellyfinHost;
|
||||||
|
|
||||||
const ip = req.ip ? req.ip.split(':').reverse()[0] : undefined;
|
const ip = req.ip;
|
||||||
|
let clientIp;
|
||||||
|
|
||||||
|
if (ip) {
|
||||||
|
if (net.isIPv4(ip)) {
|
||||||
|
clientIp = ip;
|
||||||
|
} else if (net.isIPv6(ip)) {
|
||||||
|
clientIp = ip.startsWith('::ffff:') ? ip.substring(7) : ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const account = await jellyfinserver.login(
|
const account = await jellyfinserver.login(
|
||||||
body.username,
|
body.username,
|
||||||
body.password,
|
body.password,
|
||||||
ip
|
clientIp
|
||||||
);
|
);
|
||||||
|
|
||||||
// Next let's see if the user already exists
|
// Next let's see if the user already exists
|
||||||
|
|||||||
Reference in New Issue
Block a user