-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom domain support (commented out SSL, it is REALLY complica…
…ted) Fixed deep link lib import Actually update Amazon AWS SDK config updates Add middleware for custom domains Cleanup code a bit
- Loading branch information
Showing
10 changed files
with
600 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const Profile = mongoose.model('Profile'); | ||
|
||
module.exports = (req, res) => { | ||
req.user.active_profile.image_url = req.body.image_url || null; | ||
if(req.body.headline) req.user.active_profile.headline = req.body.headline; | ||
if(req.body.subtitle) req.user.active_profile.subtitle = req.body.subtitle; | ||
if(req.body.handle) req.user.active_profile.handle = req.body.handle; | ||
if(req.body.visibility) req.user.active_profile.visibility = req.body.visibility; | ||
if(typeof req.body.custom_css != 'undefined') req.user.active_profile.custom_css = req.body.custom_css || ''; | ||
if(typeof req.body.custom_html != 'undefined') req.user.active_profile.custom_html = req.body.custom_html || ''; | ||
req.user.active_profile.image_url = req.body.image_url || null; | ||
if (req.body.headline) req.user.active_profile.headline = req.body.headline; | ||
if (req.body.subtitle) req.user.active_profile.subtitle = req.body.subtitle; | ||
if (req.body.handle) req.user.active_profile.handle = req.body.handle; | ||
if (req.body.visibility) req.user.active_profile.visibility = req.body.visibility; | ||
if (typeof req.body.custom_css != 'undefined') req.user.active_profile.custom_css = req.body.custom_css || ''; | ||
if (typeof req.body.custom_html != 'undefined') req.user.active_profile.custom_html = req.body.custom_html || ''; | ||
|
||
if (req.body.custom_domain) { | ||
req.user.active_profile.custom_domain = req.body.custom_domain; | ||
} | ||
|
||
req.user.active_profile.save((err, profile) => { | ||
if(err) return res.send(err); | ||
res.send(profile); | ||
}) | ||
req.user.active_profile.save((err, profile) => { | ||
if (err) return res.send(err); | ||
res.send(profile); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
// functions/middleware/auth.js | ||
|
||
const mongoose = require('mongoose'); | ||
const bcrypt = require('bcrypt-nodejs'); | ||
const jwt = require('jsonwebtoken'); | ||
|
||
const config = global.config; | ||
|
||
const User = mongoose.model('User'); | ||
const Profile = mongoose.model('Profile'); | ||
|
||
module.exports = function(req, res, next) { | ||
const response = res; | ||
if(req.query.token) req.body.token = req.query.token; | ||
if(!req.body.token) return res.status(400).send('Missing token'); | ||
jwt.verify(req.body.token, config.secret, function(err, decoded) { | ||
if(err) return res.status(400).send(err); | ||
if(!decoded.email) return res.status(400).send('Unable to verify user, returning to sign in'); | ||
User.findOne({email: decoded.email}) | ||
.populate('active_profile') | ||
.exec(function(err, user) { | ||
if(err) res.send(err); | ||
req.user = user; | ||
next(); | ||
}); | ||
}) | ||
module.exports = function (req, res, next) { | ||
if (req.query.token) req.body.token = req.query.token; | ||
if (!req.body.token) return res.status(400).send('Missing token'); | ||
jwt.verify(req.body.token, config.secret, function (err, decoded) { | ||
if (err) return res.status(400).send(err); | ||
if (!decoded.email) return res.status(400).send('Unable to verify user, returning to sign in'); | ||
User.findOne({email: decoded.email}) | ||
.populate('active_profile') | ||
.exec(function (err, user) { | ||
if (err) res.send(err); | ||
req.user = user; | ||
next(); | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const mongoose = require('mongoose'); | ||
const config = global.config; | ||
|
||
const Profile = mongoose.model('Profile'); | ||
|
||
module.exports = async function (req, res, next) { | ||
let host = req.hostname; | ||
let clientDomain = config.clientDomain; | ||
|
||
let profile = await Profile.findOne({custom_domain: host}).exec(); | ||
|
||
if (!profile || profile.visibility === "unpublished") | ||
return next(); | ||
|
||
let user = profile.parent; | ||
let handle = profile.handle; | ||
|
||
let url = `${clientDomain}/u/${handle}`; | ||
|
||
if (user) { | ||
|
||
res.status(200).send(`<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
</head> | ||
<body> | ||
<iframe | ||
src='${url}' | ||
style=" | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
width: 100%; | ||
border: none; | ||
margin: 0; | ||
padding: 0; | ||
overflow: hidden; | ||
z-index: 999999; | ||
height: 100%; | ||
"> | ||
</iframe> | ||
</body> | ||
</html>`); | ||
|
||
return; | ||
} | ||
|
||
return next(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.