Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My profile - edit my details form view - WIP #62

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ const router = require('express').Router();
const passport = require('passport');

const home = require('./home');
const profileDetails = require('./profileDetails');
// const auth = require('./auth');

router.get('/', home.get);

// MIDDLEWARE to ensure used is authenticated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we start collecting middleware, we should modularise them.

function ensureAuthenticated(req, res, next) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should es6 here

if (req.isAuthenticated()) {
// req.user is available for use here
return next();
}
// denied - should redirect to login
res.redirect('/');
}

// auth routes
router.get(
'/auth/github/signup',
passport.authenticate('github', { scope: ['read:org'] }),
passport.authenticate('github', { scope: ['read:org'] })
);

router.get(
Expand All @@ -30,6 +41,12 @@ router.get('/auth/github/logout', (req, res) => {
req.logout();
res.redirect('/');
});

router.get(
'/myprofile/mydetails/edit', ensureAuthenticated, profileDetails.get
);


// router.get('/auth/github/signup', auth.signup);
// router.get('/auth/github/callback', auth.signupCallback);
// router.get('/auth/github/logout', auth.logout);
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/profileDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.get = (req, res) => {
res.render('profileDetails', { activePage: { profile: true }, loggedIn: true });
};
34 changes: 34 additions & 0 deletions src/views/profileDetails.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<h1>My Details</h1>
<form novalidate>
<span>* Required</span>
<label for="full_name">Full Name *
<input id="full_name" type="text" />
</label>
<label for="github_handle">GitHub/Gitter Username *
<input id="github_handle" type="text" />
</label>
<label for="fac_campus">FAC Location *
<select id="fac_campus">
<option value="London">London</option>
<option value="Nazareth">Nazareth</option>
<option value="Gaza">Gaza</option>
</select>
</label>
<label for="fac_number">FAC Cohort Number *
<input id="fac_number" type="number" />
</label>
<label for="tech_stack">Tech Stack
<select id="tech_stack">
<option value="JavaScript">JavaScript</option>
<option value="HTML">HTML</option>
<option value="CSS3">CSS3</option>
</select>
</label>
<label for="linkedin_url">LinkedIn URL
<input id="linkedin_url" type="text" />
</label>
<label for="twitter_handle">Twitter Handle
<input id="twitter_handle" type="text" />
</label>
<button>Submit</button>
</form>