feat: login bg + bypass + hide local option
This commit is contained in:
@@ -55,6 +55,7 @@ defaults:
|
||||
darkMode: false
|
||||
auth:
|
||||
autoLogin: false
|
||||
hideLocal: false
|
||||
loginBgUrl: ''
|
||||
audience: 'urn:wiki.js'
|
||||
tokenExpiration: '30m'
|
||||
|
@@ -33,7 +33,17 @@ router.get('/login', async (req, res, next) => {
|
||||
socialStrategies
|
||||
})
|
||||
} else {
|
||||
res.render('login')
|
||||
// -> Bypass Login
|
||||
if (WIKI.config.auth.autoLogin && !req.query.all) {
|
||||
const stg = await WIKI.models.authentication.query().orderBy('order').first()
|
||||
const stgInfo = _.find(WIKI.data.authentication, ['key', stg.strategyKey])
|
||||
if (!stgInfo.useForm) {
|
||||
return res.redirect(`/login/${stg.key}`)
|
||||
}
|
||||
}
|
||||
// -> Show Login
|
||||
const bgUrl = !_.isEmpty(WIKI.config.auth.loginBgUrl) ? WIKI.config.auth.loginBgUrl : '/_assets/img/splash/1.jpg'
|
||||
res.render('login', { bgUrl, hideLocal: WIKI.config.auth.hideLocal })
|
||||
}
|
||||
})
|
||||
|
||||
|
@@ -22,6 +22,7 @@ module.exports = {
|
||||
...WIKI.config.features,
|
||||
...WIKI.config.security,
|
||||
authAutoLogin: WIKI.config.auth.autoLogin,
|
||||
authHideLocal: WIKI.config.auth.hideLocal,
|
||||
authLoginBgUrl: WIKI.config.auth.loginBgUrl,
|
||||
authJwtAudience: WIKI.config.auth.audience,
|
||||
authJwtExpiration: WIKI.config.auth.tokenExpiration,
|
||||
@@ -67,6 +68,7 @@ module.exports = {
|
||||
|
||||
WIKI.config.auth = {
|
||||
autoLogin: _.get(args, 'authAutoLogin', WIKI.config.auth.autoLogin),
|
||||
hideLocal: _.get(args, 'authHideLocal', WIKI.config.auth.hideLocal),
|
||||
loginBgUrl: _.get(args, 'authLoginBgUrl', WIKI.config.auth.loginBgUrl),
|
||||
audience: _.get(args, 'authJwtAudience', WIKI.config.auth.audience),
|
||||
tokenExpiration: _.get(args, 'authJwtExpiration', WIKI.config.auth.tokenExpiration),
|
||||
|
@@ -34,6 +34,7 @@ type SiteMutation {
|
||||
contentLicense: String
|
||||
logoUrl: String
|
||||
authAutoLogin: Boolean
|
||||
authHideLocal: Boolean
|
||||
authLoginBgUrl: String
|
||||
authJwtAudience: String
|
||||
authJwtExpiration: String
|
||||
@@ -71,6 +72,7 @@ type SiteConfig {
|
||||
contentLicense: String!
|
||||
logoUrl: String!
|
||||
authAutoLogin: Boolean
|
||||
authHideLocal: Boolean
|
||||
authLoginBgUrl: String
|
||||
authJwtAudience: String
|
||||
authJwtExpiration: String
|
||||
|
@@ -36,11 +36,11 @@ module.exports = class Authentication extends Model {
|
||||
|
||||
static async getStrategies() {
|
||||
const strategies = await WIKI.models.authentication.query().orderBy('order')
|
||||
return _.sortBy(strategies.map(str => ({
|
||||
return strategies.map(str => ({
|
||||
...str,
|
||||
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
|
||||
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
|
||||
})), ['key'])
|
||||
}))
|
||||
}
|
||||
|
||||
static async getStrategiesForLegacyClient() {
|
||||
|
@@ -2,4 +2,7 @@ extends master.pug
|
||||
|
||||
block body
|
||||
#root.is-fullscreen
|
||||
login
|
||||
login(
|
||||
bg-url=bgUrl
|
||||
hide-local=hideLocal
|
||||
)
|
||||
|
Reference in New Issue
Block a user