Login Invite

Login invite script in logininvite.ejs
This commit is contained in:
Georg Reisinger 2019-02-13 11:12:11 +01:00
parent 87e7673513
commit 61f74c0d44
2 changed files with 60 additions and 4 deletions

View File

@ -331,15 +331,15 @@ router.post("/maninvite", async (req, res) => {
res.status(200).send(postgres.manInvite(req.body.sl_id, uid)); res.status(200).send(postgres.manInvite(req.body.sl_id, uid));
} }
catch(err) { catch(err) {
console.log(error); console.error(error);
} }
}).catch(function(error) { }).catch(function(error) {
console.log(error) console.error(error)
}); });
}); });
router.get("/invite/", async (req, res) => { router.get("/invite/:invitelink", async (req, res) => {
res.status(200).send("userid"); res.status(200).render("invitelogin", {invitelink: req.params.invitelink});
}); });

View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
authDomain: "test-667ca.firebaseapp.com",
databaseURL: "https://test-667ca.firebaseio.com",
projectId: "test-667ca",
storageBucket: "test-667ca.appspot.com",
messagingSenderId: "221332577314"
};
firebase.initializeApp(config);
function checkAuth() {
firebase.auth().onAuthStateChanged(async function (user) {
if (user) {
try {
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (
idToken) {
console.log("Vor Replace");
window.location.replace("/invite/" + idToken + "/" + invitelink);
}).catch(function (error) {
console.error("Get id token client error: ", error)
});
} catch {
console.error("checkAuth error: ")
}
// document.getElementById("loginbutton").style.display = "none";
//
} else {
// document.getElementById("loginbutton").style.display = "block";
console.log("Check Auth error", user)
}
})
var user = firebase.auth().currentUser;
}
window.onload = function () {
checkAuth();
}
</script>
</head>
<body>
</body>
</html>