session-sync-auth-site 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/createUser.js +1 -0
- package/src/getLoginLink.js +3 -1
- package/src/updateUserAccount.js +1 -0
package/README.md
CHANGED
|
@@ -115,7 +115,8 @@ app.post(`create-user`, (req, res, next) => {
|
|
|
115
115
|
app.post(`get-login-link`, (req, res, next) => {
|
|
116
116
|
const loginLink = await getLoginLink({
|
|
117
117
|
email: req.body.email,
|
|
118
|
-
redirectUrl: req.body.redirectUrl, //
|
|
118
|
+
redirectUrl: req.body.redirectUrl, // must begin with the frontend domain (default: req.headers.origin)
|
|
119
|
+
origin: `https://my-backend-domain.com`, // default: req.headers.origin
|
|
119
120
|
req,
|
|
120
121
|
})
|
|
121
122
|
res.send({ loginLink })
|
package/package.json
CHANGED
package/src/createUser.js
CHANGED
package/src/getLoginLink.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
const fetch = require('node-fetch')
|
|
1
2
|
const jwt = require('jsonwebtoken')
|
|
2
3
|
|
|
3
4
|
const getLoginLink = async ({
|
|
4
5
|
email,
|
|
5
6
|
redirectUrl, // defaults to req.headers.origin
|
|
7
|
+
origin, // defaults to req.headers.origin
|
|
6
8
|
req, // either this or `setup` is required
|
|
7
9
|
setup, // keys: siteId, authDomain, and jwtSecret
|
|
8
10
|
}={}) => {
|
|
9
11
|
|
|
10
12
|
redirectUrl = redirectUrl || req.headers.origin
|
|
13
|
+
origin = origin || req.headers.origin
|
|
11
14
|
|
|
12
15
|
const {
|
|
13
16
|
siteId,
|
|
@@ -16,7 +19,6 @@ const getLoginLink = async ({
|
|
|
16
19
|
protocol=req.sessionSyncAuthProtocol || `https`,
|
|
17
20
|
} = setup || await req.getSessionSyncAuthSetupInfo()
|
|
18
21
|
|
|
19
|
-
const origin = (redirectUrl.match(/^https?:\/\/[^/]+/, '') || {})[0]
|
|
20
22
|
const loggedInRedirectUrl = `${redirectUrl}${/\?/.test(redirectUrl) ? `&` : `?`}action=successfulLogin&origin=${encodeURIComponent(origin)}&accessToken=ACCESS_TOKEN`
|
|
21
23
|
|
|
22
24
|
const getLoginLinkResult = await fetch(
|
package/src/updateUserAccount.js
CHANGED