mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 09:42:30 +00:00
Move auth parts of top menu out of config and into web templates.
Move the remaining configuration into a new config var: `nav.header_extras`. Add a `nav.showSubscriptionLink` var to control visibility of subscription link in the Account menu. This will allow admins to more easily configure extra links in the top navigation bar, without the danger of overwriting the important auth menus.
This commit is contained in:
parent
f5ced03074
commit
731f280e2e
3 changed files with 42 additions and 47 deletions
|
@ -244,17 +244,8 @@ module.exports = (app, webRouter, apiRouter)->
|
||||||
for key, value of Settings.nav
|
for key, value of Settings.nav
|
||||||
res.locals.nav[key] = _.clone(Settings.nav[key])
|
res.locals.nav[key] = _.clone(Settings.nav[key])
|
||||||
res.locals.templates = Settings.templateLinks
|
res.locals.templates = Settings.templateLinks
|
||||||
try
|
if res.locals.nav.header
|
||||||
externalAuth = res.locals.externalAuthenticationSystemUsed()
|
console.error {}, "The `nav.header` setting is no longer supported, use `nav.header_extras` instead"
|
||||||
if externalAuth and res.locals.nav.header?
|
|
||||||
# filter out '/register' link
|
|
||||||
res.locals.nav.header = _.filter(
|
|
||||||
res.locals.nav.header,
|
|
||||||
(h) ->
|
|
||||||
h.url != '/register'
|
|
||||||
)
|
|
||||||
catch error
|
|
||||||
logger.error {error}, "error while trying to filter out '/register' links from header"
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
webRouter.use (req, res, next) ->
|
webRouter.use (req, res, next) ->
|
||||||
|
|
|
@ -24,7 +24,10 @@ nav.navbar.navbar-default
|
||||||
li
|
li
|
||||||
a(href="/admin/user") Manage Users
|
a(href="/admin/user") Manage Users
|
||||||
|
|
||||||
each item in nav.header
|
|
||||||
|
// loop over header_extras
|
||||||
|
each item in nav.header_extras
|
||||||
|
|
||||||
if ((item.only_when_logged_in && getSessionUser()) || (item.only_when_logged_out && (!getSessionUser())) || (!item.only_when_logged_out && !item.only_when_logged_in))
|
if ((item.only_when_logged_in && getSessionUser()) || (item.only_when_logged_out && (!getSessionUser())) || (!item.only_when_logged_out && !item.only_when_logged_in))
|
||||||
if item.dropdown
|
if item.dropdown
|
||||||
li.dropdown(class=item.class, dropdown)
|
li.dropdown(class=item.class, dropdown)
|
||||||
|
@ -35,9 +38,6 @@ nav.navbar.navbar-default
|
||||||
each child in item.dropdown
|
each child in item.dropdown
|
||||||
if child.divider
|
if child.divider
|
||||||
li.divider
|
li.divider
|
||||||
else if child.user_email
|
|
||||||
li
|
|
||||||
div.subdued #{getUserEmail()}
|
|
||||||
else
|
else
|
||||||
li
|
li
|
||||||
if child.url
|
if child.url
|
||||||
|
@ -50,7 +50,35 @@ nav.navbar.navbar-default
|
||||||
a(href=item.url, class=item.class) !{translate(item.text)}
|
a(href=item.url, class=item.class) !{translate(item.text)}
|
||||||
else
|
else
|
||||||
| !{translate(item.text)}
|
| !{translate(item.text)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// logged out
|
||||||
|
if !getSessionUser()
|
||||||
|
// register link
|
||||||
|
if !externalAuthenticationSystemUsed()
|
||||||
|
li
|
||||||
|
a(href="/register") #{translate('register')}
|
||||||
|
|
||||||
|
// login link
|
||||||
|
li
|
||||||
|
a(href="/login") #{translate('log_in')}
|
||||||
|
|
||||||
|
// projects link and account menu
|
||||||
|
if getSessionUser()
|
||||||
|
li
|
||||||
|
a(href="/projects") #{translate('Projects')}
|
||||||
|
li.dropdown(dropdown)
|
||||||
|
a.dropbodw-toggle(href, dropdown-toggle)
|
||||||
|
| #{translate('Account')}
|
||||||
|
b.caret
|
||||||
|
ul.dropdown-menu
|
||||||
|
li
|
||||||
|
div.subdued #{getUserEmail()}
|
||||||
|
li.divider
|
||||||
|
li
|
||||||
|
a(href="/user/settings") #{translate('Account Settings')}
|
||||||
|
if nav.showSubscriptionLink
|
||||||
|
li
|
||||||
|
a(href="/user/subscription") #{translate('subscription')}
|
||||||
|
li.divider
|
||||||
|
li
|
||||||
|
a(href="/logout") #{translate('log_out')}
|
||||||
|
|
|
@ -335,35 +335,11 @@ module.exports = settings =
|
||||||
url: "https://github.com/sharelatex/sharelatex"
|
url: "https://github.com/sharelatex/sharelatex"
|
||||||
}]
|
}]
|
||||||
|
|
||||||
header: [{
|
showSubscriptionLink: false
|
||||||
text: "register"
|
|
||||||
url: "/register"
|
header_extras: []
|
||||||
only_when_logged_out: true
|
# Example:
|
||||||
}, {
|
# header_extras: [{text: "Some Page", url: "http://example.com/some/page", class: "subdued"}]
|
||||||
text: "log_in"
|
|
||||||
url: "/login"
|
|
||||||
only_when_logged_out: true
|
|
||||||
}, {
|
|
||||||
text: "Projects"
|
|
||||||
url: "/project"
|
|
||||||
only_when_logged_in: true
|
|
||||||
}, {
|
|
||||||
text: "Account"
|
|
||||||
only_when_logged_in: true
|
|
||||||
dropdown: [{
|
|
||||||
user_email: true
|
|
||||||
},{
|
|
||||||
divider: true
|
|
||||||
}, {
|
|
||||||
text: "Account Settings"
|
|
||||||
url: "/user/settings"
|
|
||||||
}, {
|
|
||||||
divider: true
|
|
||||||
}, {
|
|
||||||
text: "Log out"
|
|
||||||
url: "/logout"
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
|
|
||||||
customisation: {}
|
customisation: {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue