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])
const onSubmit = () => {
fetch(`/api/door/auth?key=${key}&rotatingKey=${key}&door=${door}`)
const onSubmit = async () => {
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 => {
if (res.status !== 200) {
setError("Incorrect PIN");

View File

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

View File

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