mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 08:25:47 +01:00
🔀 Merge pull request #179 from ajnart/ajnart/issue174
✨Password / Login Page
This commit is contained in:
25
src/pages/api/configs/tryPassword.tsx
Normal file
25
src/pages/api/configs/tryPassword.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
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) {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
}
|
||||
return res.status(200).json({
|
||||
success: false,
|
||||
});
|
||||
}
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
// Filter out if the reuqest is a POST or a GET
|
||||
if (req.method === 'POST') {
|
||||
return Post(req, res);
|
||||
}
|
||||
return res.status(405).json({
|
||||
statusCode: 405,
|
||||
message: 'Method not allowed',
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user