Skip to content

these changes pass the redirect through #7

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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