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
38575931
Commit
38575931
authored
Feb 23, 2018
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: azure ad email getter
parent
01545f56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
user.js
server/models/user.js
+15
-2
No files found.
server/models/user.js
View file @
38575931
...
...
@@ -48,6 +48,7 @@ var userSchema = Mongoose.Schema({
userSchema
.
statics
.
processProfile
=
(
profile
)
=>
{
let
primaryEmail
=
''
let
name
=
''
if
(
_
.
isArray
(
profile
.
emails
))
{
let
e
=
_
.
find
(
profile
.
emails
,
[
'primary'
,
true
])
primaryEmail
=
(
e
)
?
e
.
value
:
_
.
first
(
profile
.
emails
).
value
...
...
@@ -57,6 +58,8 @@ userSchema.statics.processProfile = (profile) => {
primaryEmail
=
profile
.
mail
}
else
if
(
profile
.
user
&&
profile
.
user
.
email
&&
profile
.
user
.
email
.
length
>
5
)
{
primaryEmail
=
profile
.
user
.
email
}
else
if
(
_
.
isString
(
profile
.
unique_name
)
&&
profile
.
unique_name
.
length
>
5
)
{
primaryEmail
=
profile
.
unique_name
}
else
{
return
Promise
.
reject
(
new
Error
(
lang
.
t
(
'auth:errors.invaliduseremail'
)))
}
...
...
@@ -64,6 +67,16 @@ userSchema.statics.processProfile = (profile) => {
profile
.
provider
=
_
.
lowerCase
(
profile
.
provider
)
primaryEmail
=
_
.
toLower
(
primaryEmail
)
if
(
_
.
has
(
profile
,
'displayName'
))
{
name
=
profile
.
displayName
}
else
if
(
_
.
has
(
profile
,
'name'
))
{
name
=
profile
.
name
}
else
if
(
_
.
has
(
profile
,
'cn'
))
{
name
=
profile
.
cn
}
else
{
name
=
_
.
split
(
primaryEmail
,
'@'
)[
0
]
}
return
db
.
User
.
findOneAndUpdate
({
email
:
primaryEmail
,
provider
:
profile
.
provider
...
...
@@ -71,7 +84,7 @@ userSchema.statics.processProfile = (profile) => {
email
:
primaryEmail
,
provider
:
profile
.
provider
,
providerId
:
profile
.
id
,
name
:
profile
.
displayName
||
profile
.
cn
||
_
.
split
(
primaryEmail
,
'@'
)[
0
]
name
},
{
new
:
true
}).
then
((
user
)
=>
{
...
...
@@ -82,7 +95,7 @@ userSchema.statics.processProfile = (profile) => {
provider
:
profile
.
provider
,
providerId
:
profile
.
id
,
password
:
''
,
name
:
profile
.
displayName
||
profile
.
name
||
profile
.
cn
,
name
,
rights
:
[{
role
:
'read'
,
path
:
'/'
,
...
...
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