mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-18 03:01:09 +01:00
🔀 Merge branch 'dev' into tests/add-tests
This commit is contained in:
@@ -2,26 +2,31 @@ import Consola from 'consola';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { tried } = req.body;
|
||||
// Try to match the password with the PASSWORD env variable
|
||||
if (tried === process.env.PASSWORD) {
|
||||
const { tried, type = 'password' } = req.body;
|
||||
// If the type of password is "edit", we run this branch to check the edit password
|
||||
if (type === 'edit') {
|
||||
if (tried === process.env.EDIT_MODE_PASSWORD) {
|
||||
process.env.DISABLE_EDIT_MODE = process.env.DISABLE_EDIT_MODE === 'true' ? 'false' : 'true';
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
}
|
||||
} else if (tried === process.env.PASSWORD) {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
}
|
||||
// Warn that there was a wrong password attempt (date : wrong password, person's IP)
|
||||
Consola.warn(
|
||||
`${new Date().toLocaleString()} : Wrong password attempt, from ${
|
||||
req.headers['x-forwarded-for']
|
||||
}`
|
||||
);
|
||||
return res.status(200).json({
|
||||
return res.status(401).json({
|
||||
success: false,
|
||||
});
|
||||
}
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
// Filter out if the request is a POST or a GET
|
||||
if (req.method === 'POST') {
|
||||
return Post(req, res);
|
||||
}
|
||||
|
||||
@@ -110,8 +110,9 @@ const handleServer = async (app: ConfigAppType): Promise<GenericMediaServer | un
|
||||
supportsMediaControl: session.SupportsMediaControl ?? false,
|
||||
currentlyPlaying: session.NowPlayingItem
|
||||
? {
|
||||
name: session.NowPlayingItem.Name as string,
|
||||
name: `${session.NowPlayingItem.SeriesName ?? session.NowPlayingItem.Name}`,
|
||||
seasonName: session.NowPlayingItem.SeasonName as string,
|
||||
episodeName: session.NowPlayingItem.Name as string,
|
||||
albumName: session.NowPlayingItem.Album as string,
|
||||
episodeCount: session.NowPlayingItem.EpisodeCount ?? undefined,
|
||||
metadata: {
|
||||
|
||||
@@ -53,6 +53,7 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) =>
|
||||
title: item.title ? decode(item.title) : undefined,
|
||||
content: decode(item.content),
|
||||
enclosure: createEnclosure(item),
|
||||
link: createLink(item),
|
||||
}))
|
||||
.sort((a: { pubDate: number }, b: { pubDate: number }) => {
|
||||
if (!a.pubDate || !b.pubDate) {
|
||||
@@ -70,6 +71,14 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) =>
|
||||
});
|
||||
};
|
||||
|
||||
const createLink = (item: any) => {
|
||||
if (item.link) {
|
||||
return item.link;
|
||||
}
|
||||
|
||||
return item.guid;
|
||||
};
|
||||
|
||||
const createEnclosure = (item: any) => {
|
||||
if (item.enclosure) {
|
||||
return item.enclosure;
|
||||
|
||||
Reference in New Issue
Block a user