Skip to content

Commit

Permalink
Merge branch 'master' into rmCreateCollBrowse
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmyers authored Dec 15, 2024
2 parents 5416fdc + 406456a commit 05402fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ function App () {
}

// User Endpoints
if (config.get('allowPublicSignup')) {
app.all('/register', views.register)
}
app.all('/register', allowPublicSignup, views.register)
app.all('/login', views.login)
app.post('/remoteLogin', forceNoHTML, views.login)
app.all('/logout', views.logout)
Expand Down Expand Up @@ -519,6 +517,18 @@ function App () {
}
}

function allowPublicSignup (req, res, next) {
if (!config.get('allowPublicSignup')) {
if (!req.accepts('text/html')) {
res.status(401).send('Public signup is not allowed')
} else {
res.redirect('/')
}
} else {
next()
}
}

function requirePublicLogin (req, res, next) {
if (config.get('requireLogin') && !req.user) {
if (!req.accepts('text/html')) {
Expand Down
7 changes: 6 additions & 1 deletion templates/layouts/default.jade
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ block body
a(href='/logout', title='Sign Out')
span.fa.fa-sign-out
span.blue-text.hidden-xs.hidden-sm Sign Out
else
else if config.allowPublicSignup
li
a(href='/login')
span.fa.fa-sign-in
span.blue-text.hidden-xs.hidden-sm Login or Register
else
li
a(href='/login')
span.fa.fa-sign-in
span.blue-text.hidden-xs.hidden-sm Login


div.clearfix
Expand Down

0 comments on commit 05402fc

Please sign in to comment.