Added Signup button as well

nodejs
Aravind142857 1 year ago
parent decfc44592
commit c6dec7838a

@ -32,7 +32,7 @@
<a href="#head" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-black mr-4 hover:bg-gray-200 hover:border hover:border-gray-200 hover:rounded text-teal-200 py-1 px-3">
C
</a>
<a href="/index.html" class="block mt-4 lg:inline-block lg:mt-0 bg-blue-600 brightness-125 border border-blue-500 rounded text-teal-200 hover:text-black py-1 px-3">
<a href="/index_1.html" class="block mt-4 lg:inline-block lg:mt-0 bg-blue-600 brightness-125 border border-blue-500 rounded text-teal-200 hover:text-black py-1 px-3">
Products (Form)
</a>
</div>

@ -33,18 +33,44 @@ app.use(sessions({
}))
app.use(cookieParser());
var session;
app.use(express.static(staticPath));
app.get('/bruh', function(req, res) {
var tagline;
var signup;
var loc;
if (req.session.userId) {
tagline = "logout";
signup = "hidden";
loc = "/__logout";
} else {
tagline = "log in";
loc = "login.html"
}
res.render('pages/index', {
tagline: tagline,
signup: signup,
loc: loc
});
})
app.get('/', function(req, res) {
console.log("Moving to a diff site");
var tagline;
var signup;
var loc;
if (req.session.userId) {
tagline = "logout";
signup = "hidden";
loc = "__logout";
} else {
tagline = "log in";
loc = "login.html";
}
res.render('pages/index', {
tagline: tagline
tagline: tagline,
signup: signup,
loc: loc
});
})
app.use(express.static(staticPath));
const GLINK_SIZE = 6;
function getRandomGLink() {
let glink = "";
@ -120,7 +146,7 @@ function calculateDistance(lat1, lat2, long1, long2) {
return (2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat2 - lat1)/2), 2) + Math.pow(Math.sin((long2 - long1)/2), 2) * Math.cos(lat1) * Math.cos(lat2))) * RADIUS_OF_EARTH_IN_MILES);
}
// app.get('/', (request, response) => {
// response.render("index.html");
// response.render("index_1.html");
// })
app.get('/node_modules/', (request, response) => {
response.redirect("./error.html");
@ -215,9 +241,27 @@ app.get('/__logout', function(req, res, cb) {
console.log(req.session);
console.log(session);
req.session.destroy();
res.redirect('/login.html');
var tagline;
var signup;
var loc;
console.log(req.session);
if ( req.session && req.session.userId) {
console.log("session valid");
tagline = "logout";
signup = "hidden";
loc = "__logout";
} else {
console.log("session invalid");
tagline = "log in";
loc = "/login.html";
}
res.render('pages/index', {
tagline: tagline,
signup: signup,
loc: loc
});
console.log("done");
res.end();
})
app.post('/__check', function(req, res) {
let user_latitude = req.body.latitude;
@ -247,7 +291,7 @@ app.post('/__check', function(req, res) {
}
})
})
app.post('/__signup', function(req, res, cb) {
app.get('/__signup', function(req, res, cb) {
console.log("Entered signup");
let email = req.body.email;
let password = req.body.password;
@ -312,15 +356,22 @@ app.post('/__login', function(req, res, cb) {
console.log(req.session);
var tagline;
var signup;
var loc;
if (req.session.userId) {
tagline = "logout";
signup = "hidden";
loc = "/__logout"
} else {
tagline = "log in";
loc = "login.html";
}
res.render('pages/index', {
tagline: tagline
tagline: tagline,
signup: signup,
loc: loc
});
/*res.redirect("/index.html");*/
/*res.redirect("/index_1.html");*/
res.end();
} else {
console.log("Wrong password");

@ -32,12 +32,18 @@
<a href="#head" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-black mr-4 hover:bg-gray-200 hover:border hover:border-gray-200 hover:rounded text-teal-200 py-1 px-3">
C
</a>
<a href="/index.html" class="block mt-4 lg:inline-block lg:mt-0 bg-blue-600 brightness-125 border border-blue-500 rounded text-teal-200 hover:text-black py-1 px-3">
<a href="index.html" class="block mt-4 lg:inline-block lg:mt-0 bg-blue-600 brightness-125 border border-blue-500 rounded text-teal-200 hover:text-black py-1 px-3">
Products (Form)
</a>
</div>
<div>
<a href="signup.html" class="inline-block <%= signup %> text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-teal-500 hover:bg-white mt-4 lg:mt-0 mr-4">
signup
</a>
</div>
<div>
<a href="/__logout" class="inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-teal-500 hover:bg-white mt-4 lg:mt-0">
<a href="<%= loc %>" class="inline-block text-sm px-4 py-2 leading-none border rounded text-white border-white hover:border-transparent hover:text-teal-500 hover:bg-white mt-4 lg:mt-0">
<%= tagline %>
</a>
</div>
@ -100,9 +106,9 @@
</form>
<hr>
<img src="./images/cat.gif">
<img src="images/cat.gif">
<p id="footer" class="object-none object-bottom">Insert Footer Here</p>
<script src="./src/index.js"></script>
<script src="src/index.js"></script>
</div>
</body>

Loading…
Cancel
Save