1 |
|
2 |
|
3 |
|
4 |
|
5 | url = require 'url'
|
6 |
|
7 | getRedirectSettings = (options, returnUrl) ->
|
8 |
|
9 | throw new Error '"options" parameter is required' if not options?
|
10 |
|
11 | defaultRedirectUri = options.redirectUrl
|
12 | useReturnUrl = options.useReturnUrl
|
13 | logoutUrl = options.logoutUrl
|
14 |
|
15 | portalLoginUrl = "/admin/site/Login.aspx"
|
16 | if returnUrl.indexOf(portalLoginUrl) isnt -1
|
17 | redirectUrl = "#{defaultRedirectUri}#{encodeURIComponent(returnUrl)}"
|
18 | return {
|
19 | returnUrl: encodeURIComponent(returnUrl)
|
20 | redirectUrl: redirectUrl
|
21 | }
|
22 |
|
23 | returnUrlParams = url.parse(returnUrl, true)
|
24 | returnUrl = returnUrlParams.pathname
|
25 | if returnUrlParams.query.previousUrl
|
26 | returnUrl = returnUrlParams.query.previousUrl
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | redirectUrl = defaultRedirectUri
|
39 | redirectUrl = "#{defaultRedirectUri}#{encodeURIComponent(returnUrl)}" if useReturnUrl
|
40 |
|
41 | return {
|
42 | returnUrl: encodeURIComponent(returnUrl)
|
43 | redirectUrl: redirectUrl
|
44 | }
|
45 |
|
46 | module.exports = getRedirectSettings
|