Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
5acc7e75
Unverified
Commit
5acc7e75
authored
Mar 17, 2023
by
Charlotte County Public Schools
Committed by
GitHub
Mar 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add new props to existing auth strategies (#6250)
parent
b5b19133
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
authentication.js
server/models/authentication.js
+9
-0
No files found.
server/models/authentication.js
View file @
5acc7e75
...
...
@@ -92,6 +92,7 @@ module.exports = class Authentication extends Model {
}
for
(
const
strategy
of
dbStrategies
)
{
let
newProps
=
false
const
strategyDef
=
_
.
find
(
WIKI
.
data
.
authentication
,
[
'key'
,
strategy
.
strategyKey
])
if
(
!
strategyDef
)
{
await
WIKI
.
models
.
authentication
.
query
().
delete
().
where
(
'key'
,
strategy
.
key
)
...
...
@@ -101,6 +102,8 @@ module.exports = class Authentication extends Model {
strategy
.
config
=
_
.
transform
(
strategyDef
.
props
,
(
result
,
value
,
key
)
=>
{
if
(
!
_
.
has
(
result
,
key
))
{
_
.
set
(
result
,
key
,
value
.
default
)
// we have some new properties added to an existing auth strategy to write to the database
newProps
=
true
}
return
result
},
strategy
.
config
)
...
...
@@ -111,6 +114,12 @@ module.exports = class Authentication extends Model {
displayName
:
strategyDef
.
title
}).
where
(
'key'
,
strategy
.
key
)
}
// write existing auth model to database with new properties and defaults
if
(
newProps
)
{
await
WIKI
.
models
.
authentication
.
query
().
patch
({
config
:
strategy
.
config
}).
where
(
'key'
,
strategy
.
key
)
}
}
WIKI
.
logger
.
info
(
`Loaded
${
WIKI
.
data
.
authentication
.
length
}
authentication strategies: [ OK ]`
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment