Skip to content
Permalink
Browse files
Add Login and Register Functionality
Users can now login and register an account in the loginpage. Actions
and methods have been added to the loginpage.handlebars and these
methods have been added as routes in index.js.

Authorising and checking what level of admin rights will be added
later.
  • Loading branch information
staplesc committed Nov 27, 2019
1 parent f3b8ee8 commit f17f033ce84d7d472311600315a3810e88bef815
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
@@ -79,7 +79,12 @@ router.get('/articles/:id', async ctx => {
* @name Register Page
* @route {GET} /register
*/
router.get('/register', async ctx => await ctx.render('register'))

router.get('/register', async ctx => {
const data = {}
if(ctx.query.msg) data.msg = ctx.query.msg
await ctx.render('loginpage')
})

/**
* The script to process new user registrations.
@@ -25,18 +25,19 @@
<button type = "button" class = "toggle-btn" onclick = "register()"> Register </button>
</section>

<form action="/login" method="post" id = "login" class = "input-group">
<form action = "/login" method = "post" id = "login" class = "input-group">
<input type = "text" name="user" class = "input-field" placeholder = "User ID" value="{{user}}" required>
<input type = "password" name="pass" class = "input-field" placeholder = "Enter Password" value="" required>
<input type = "checkbox" class = "check-box"> <span> Remember Password </span>
<!-- <input type = "checkbox" class = "check-box"> <span> Remember Password </span> -->
<button type = "submit" class = "submit-btn"> Log in </button>
</form>

<form id = "register" class = "input-group">
<input type = "text" class = "input-field" placeholder = "User ID" required>
<input type = "email" class = "input-field" placeholder = "Email" required>
<input type = "checkbox" class = "check-box"> <span> I agree to the terms + conditions </span>
<button type = "submit" class = "submit-btn"> Register </button>
<form action = "/register" enctype = "multipart/form-data" method = "post" id = "register" class = "input-group">
<input type = "text" name="user" class = "input-field" placeholder = "User ID" value = "" required>
<!-- <input type = "email" class = "input-field" placeholder = "Email" required> -->
<input type = "password" name="pass" class = "input-field" placeholder = "Password" value = "" required>
<!-- <input type = "checkbox" class = "check-box"> <span> I agree to the terms + conditions </span> -->
<button type = "submit" class = "submit-btn" value = "Create"> Register </button>
</form>
</section>
</section>

0 comments on commit f17f033

Please sign in to comment.