This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //generate password reset hash | |
| userSchema.methods.generatePasswordResetHash = function(){ | |
| //create hash object, then create a sha512 hash of the user's current password | |
| //and return hash | |
| const resetHash = crypto.createHash('sha512').update(this.password).digest('hex') | |
| return resetHash; | |
| } | |
| //verify password reset hash | |
| userSchema.methods.verifyPasswordResetHash = function(resetHash = undefined){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //SOME CONSTANTS HERE | |
| DEFINE ('DB_HOST', 'localhost'); | |
| DEFINE ('DB_USER', ''); | |
| DEFINE ('DB_PASS', ''); | |
| DEFINE ('DB_NAME', ''); | |
| class DatabaseClass{ | |
| private $connection = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //route to login | |
| app.get('/login', (req, res) => { | |
| //user is logged in | |
| loggedIn = true | |
| //redirect to homepage | |
| return res.redirect('/') | |
| }) | |
| //route to logout | |
| app.get('/logout', (req, res) => { | |
| //user is logged in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% if(loggedIn === true) { %> | |
| <li class="nav-item"> | |
| <a class="nav-link text-danger" href="/logout">Logout</a> | |
| </li> | |
| <% }else{ %> | |
| <li class="nav-item"> | |
| <a class="nav-link text-success" href="/login">Login</a> | |
| </li> | |
| <% } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!Doctype html> | |
| <html> | |
| <head> | |
| <%- include('./layouts/head') %> | |
| </head> | |
| <body> | |
| <header> | |
| <%- include('./layouts/navbar') %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //route to fruits | |
| app.get( '/fruits', (req, res) => { | |
| //our fruits array | |
| const fruitsAry = ['apple', 'mango', 'guava', 'banana', 'pineapple'] | |
| //render the template for the fruits page & send data as json | |
| res.render('fruits', {fruitsAry}); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!Doctype html> | |
| <html> | |
| <head> | |
| <%- include('./layouts/head') %> | |
| </head> | |
| <body> | |
| <header> | |
| <%- include('./layouts/navbar') %> | |
| </header> | |
| <main> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Footer --> | |
| <footer class="bg-light text-center "> | |
| <!-- Grid container --> | |
| <div class="container p-4"> | |
| <!-- Section: Text --> | |
| <section class="mb-4"> | |
| <p> | |
| Lorem ipsum dolor sit amet consectetur adipisicing elit. Sunt | |
| distinctio earum repellat quaerat voluptatibus placeat nam, | |
| commodi optio pariatur est quia magnam eum harum corrupti dicta, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Navbar --> | |
| <nav class="navbar navbar-expand-lg navbar-light bg-light"> | |
| <!-- Container wrapper --> | |
| <div class="container-fluid"> | |
| <!-- Toggle button --> | |
| <button class="navbar-toggler" type="button" data-mdb-toggle="collapse" | |
| data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" | |
| aria-label="Toggle navigation"> | |
| <i class="fas fa-bars"></i> | |
| </button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Font Awesome --> | |
| <link | |
| href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" | |
| rel="stylesheet" | |
| /> | |
| <!-- Google Fonts --> | |
| <link | |
| href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" | |
| rel="stylesheet" | |
| /> |