add ip address to the auth
Some checks failed
Build and push image for doorman / docker (push) Failing after 2m40s

This commit is contained in:
Martin Dimitrov 2024-09-24 20:06:44 -07:00
parent 0bac206bdd
commit 9aaa639d8d
3 changed files with 15 additions and 4 deletions

View File

@ -27,8 +27,18 @@ export const AuthComponent = ({ door, secret, authMode, onError, onUnlock, runCh
} }
}, [runCheck]) }, [runCheck])
const onSubmit = () => { const onSubmit = async () => {
fetch(`/api/door/auth?key=${key}&rotatingKey=${key}&door=${door}`) const ip = await fetch('https://api.ipify.org?format=json')
.then(response => response.json())
.then(data => {
return data.ip;
})
.catch(error => {
console.log('Error:', error);
return "null";
});
fetch(`/api/door/auth?key=${key}&rotatingKey=${key}&door=${door}&ip=${ip}`)
.then(async res => { .then(async res => {
if (res.status !== 200) { if (res.status !== 200) {
setError("Incorrect PIN"); setError("Incorrect PIN");

View File

@ -9,12 +9,12 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:5000', target: 'http://localhost:3000',
changeOrigin: true, changeOrigin: true,
}, },
}, },
host: "0.0.0.0", host: "0.0.0.0",
port: 3000 port: 8080
}, },
build: { build: {
outDir: "dist", outDir: "dist",

View File

@ -34,6 +34,7 @@ exports.handler = async function(context, event, callback) {
const fingerprint = { const fingerprint = {
method: "PIN", method: "PIN",
userAgent: event.request.headers['user-agent'], userAgent: event.request.headers['user-agent'],
ip: event.ip,
}; };
// take timeout from the query string // take timeout from the query string