mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Lookup users by email hostname using new field
This commit is contained in:
@@ -1,2 +1,7 @@
|
||||
UserGetter = require("../User/UserGetter")
|
||||
|
||||
module.exports = InstitutionsController =
|
||||
confirmDomain: (req, res, next = (error) ->) ->
|
||||
confirmDomain: (req, res, next) ->
|
||||
hostname = req.body.hostname
|
||||
UserGetter.getUsersByHostname hostname, {_id:1, emails:1}, (error, users) ->
|
||||
res.json {hostname: hostname, wub: users}
|
||||
|
||||
@@ -58,6 +58,11 @@ module.exports = UserGetter =
|
||||
# well
|
||||
@getUserByMainEmail email, projection, callback
|
||||
|
||||
getUsersByHostname: (hostname, projection, callback = (error, users) ->) ->
|
||||
hostname = hostname.trim()
|
||||
query = emails: { $exists: true }, 'emails.hostname': hostname
|
||||
db.users.find query, projection, callback
|
||||
|
||||
getUsers: (user_ids, projection, callback = (error, users) ->) ->
|
||||
try
|
||||
user_ids = user_ids.map (u) -> ObjectId(u.toString())
|
||||
|
||||
Reference in New Issue
Block a user