mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
feat(auth): send real information on login (#470)
* feat(auth): send real ip on login * feat(auth): send application name on login
This commit is contained in:
@@ -104,9 +104,9 @@ class JellyfinAPI {
|
|||||||
|
|
||||||
let authHeaderVal = '';
|
let authHeaderVal = '';
|
||||||
if (this.authToken) {
|
if (this.authToken) {
|
||||||
authHeaderVal = `MediaBrowser Client="Overseerr", Device="Axios", DeviceId="${deviceId}", Version="10.8.0", Token="${authToken}"`;
|
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="10.8.0", Token="${authToken}"`;
|
||||||
} else {
|
} else {
|
||||||
authHeaderVal = `MediaBrowser Client="Overseerr", Device="Axios", DeviceId="${deviceId}", Version="10.8.0"`;
|
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="10.8.0"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.axios = axios.create({
|
this.axios = axios.create({
|
||||||
@@ -121,14 +121,23 @@ class JellyfinAPI {
|
|||||||
|
|
||||||
public async login(
|
public async login(
|
||||||
Username?: string,
|
Username?: string,
|
||||||
Password?: string
|
Password?: string,
|
||||||
|
ClientIP?: string
|
||||||
): Promise<JellyfinLoginResponse> {
|
): Promise<JellyfinLoginResponse> {
|
||||||
try {
|
try {
|
||||||
|
const headers = ClientIP
|
||||||
|
? {
|
||||||
|
'X-Forwarded-For': ClientIP,
|
||||||
|
}
|
||||||
|
: {};
|
||||||
const account = await this.axios.post<JellyfinLoginResponse>(
|
const account = await this.axios.post<JellyfinLoginResponse>(
|
||||||
'/Users/AuthenticateByName',
|
'/Users/AuthenticateByName',
|
||||||
{
|
{
|
||||||
Username: Username,
|
Username: Username,
|
||||||
Pw: Password,
|
Pw: Password,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: headers,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,13 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
|
|||||||
? jellyfinHost.slice(0, -1)
|
? jellyfinHost.slice(0, -1)
|
||||||
: jellyfinHost;
|
: jellyfinHost;
|
||||||
|
|
||||||
const account = await jellyfinserver.login(body.username, body.password);
|
const ip = req.ip ? req.ip.split(':').reverse()[0] : undefined;
|
||||||
|
const account = await jellyfinserver.login(
|
||||||
|
body.username,
|
||||||
|
body.password,
|
||||||
|
ip
|
||||||
|
);
|
||||||
|
|
||||||
// Next let's see if the user already exists
|
// Next let's see if the user already exists
|
||||||
user = await userRepository.findOne({
|
user = await userRepository.findOne({
|
||||||
where: { jellyfinUserId: account.User.Id },
|
where: { jellyfinUserId: account.User.Id },
|
||||||
|
|||||||
Reference in New Issue
Block a user