Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
laboite
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
apps.education
laboite
Commits
08a9ac11
Commit
08a9ac11
authored
Jul 24, 2020
by
Boiget Boiget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing files
parent
598c3d42
Pipeline
#2332
passed with stages
in 5 minutes and 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
app/imports/api/domains.js
app/imports/api/domains.js
+16
-0
app/imports/api/logging.js
app/imports/api/logging.js
+24
-0
No files found.
app/imports/api/domains.js
0 → 100644
View file @
08a9ac11
import
{
Meteor
}
from
'
meteor/meteor
'
;
import
logServer
from
'
./logging
'
;
// checks if the domain part of an email address matches whitelisted domains
export
default
function
checkDomain
(
email
)
{
let
res
=
false
;
const
domainMail
=
email
.
split
(
'
@
'
)[
1
];
const
whiteDomains
=
Meteor
.
settings
.
private
.
whiteDomains
||
[];
whiteDomains
.
forEach
((
whiteDomain
)
=>
{
if
(
new
RegExp
(
whiteDomain
).
test
(
domainMail
))
{
logServer
(
` Email domain matches
${
whiteDomain
}
: user activated`
);
res
=
true
;
}
});
return
res
;
}
app/imports/api/logging.js
0 → 100644
View file @
08a9ac11
import
{
Meteor
}
from
'
meteor/meteor
'
;
import
i18n
from
'
meteor/universe:i18n
'
;
import
{
createNotification
}
from
'
./notifications/methods
'
;
const
levels
=
[
'
info
'
,
'
warning
'
,
'
error
'
];
function
logServer
(
message
,
level
=
'
info
'
,
userNotify
=
null
)
{
if
(
!
levels
.
includes
(
level
))
throw
new
Meteor
.
Error
(
'
api.logging.logServer
'
,
i18n
.
__
(
'
api.logging.unknownLogLevel
'
));
console
.
log
(
message
);
if
(
userNotify
)
{
const
user
=
Meteor
.
users
.
findOne
(
userNotify
);
if
(
user
)
{
const
notifData
=
{
userId
:
userNotify
,
title
:
i18n
.
__
(
`api.logging.
${
level
}
`
),
content
:
message
,
type
:
level
,
};
createNotification
.
_execute
({},
{
data
:
notifData
});
}
}
}
export
default
logServer
;
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