Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.get('/', (req, res) => {
return res.render('index')
return res.render('index', { redirect: req.query.redirect || '' });
});

app.post('/', readmeLogin);
Expand Down
2 changes: 2 additions & 0 deletions readme-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var { URL } = require('url');
// This should do all of the work to login and verify the user is valid
module.exports = (req, res) => {
var { email, password } = req.body;
var redirect = req.body.redirect || req.query.redirect;

console.log('Use these credentials to log the user in somewhere:', { email, password });

Expand All @@ -28,6 +29,7 @@ module.exports = (req, res) => {
var jwt = sign(user, process.env.JWT_SECRET);
var url = new URL(process.env.HUB_URL);
url.searchParams.set('auth_token', jwt);
if (redirect) url.searchParams.set('redirect', redirect);
console.log('Redirecting to: ', url.toString());
return res.redirect(url);
}
1 change: 1 addition & 0 deletions views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends layout
block content
h1 Demo Login
form(method='POST')
input(type='hidden', name='redirect', value=redirect)
.form-group
label Email
input.form-control(name='email' required value='[email protected]')
Expand Down