Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
86d8cb0b
Commit
86d8cb0b
authored
Sep 26, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: fix in jio local gadget 401 redirect
parent
2b7a3144
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
51 deletions
+53
-51
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_local_jio_js.js
...plateItem/web_page_module/gadget_officejs_local_jio_js.js
+53
-51
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_local_jio_js.js
View file @
86d8cb0b
...
@@ -3,6 +3,54 @@
...
@@ -3,6 +3,54 @@
(
function
(
window
,
rJS
,
jIO
,
RSVP
,
UriTemplate
,
console
)
{
(
function
(
window
,
rJS
,
jIO
,
RSVP
,
UriTemplate
,
console
)
{
"
use strict
"
;
"
use strict
"
;
function
redirectToLogin
(
gadget
,
error
)
{
var
regexp
,
site
,
login_page
;
if
(
gadget
.
state_parameter_dict
.
jio_storage_name
===
"
ERP5
"
)
{
regexp
=
/^X-Delegate uri=
\"(
http
[
s
]?
:
\/\/[\/\-\[\]
{}()*+=:?&.,
\\\^
$|#
\s\w
%
]
+
)\"
$/
;
login_page
=
error
.
target
.
getResponseHeader
(
'
WWW-Authenticate
'
);
if
(
regexp
.
test
(
login_page
))
{
return
gadget
.
getUrlFor
({
command
:
'
login
'
,
absolute_url
:
true
})
.
push
(
function
(
came_from
)
{
return
gadget
.
redirect
({
command
:
'
raw
'
,
options
:
{
url
:
UriTemplate
.
parse
(
regexp
.
exec
(
login_page
)[
1
])
.
expand
({
came_from
:
came_from
})
}
});
});
}
}
if
(
gadget
.
state_parameter_dict
.
jio_storage_name
===
"
DAV
"
)
{
regexp
=
/^Nayookie login_url=
(
http
[
s
]?
:
\/\/[\/\-\[\]
{}()*+=:?&.,
\\\^
$|#
\s\w
%
]
+
)
$/
;
login_page
=
error
.
target
.
getResponseHeader
(
'
WWW-Authenticate
'
);
if
(
regexp
.
test
(
login_page
))
{
site
=
UriTemplate
.
parse
(
regexp
.
exec
(
login_page
)[
1
]
).
expand
({
back_url
:
window
.
location
.
href
,
origin
:
window
.
location
.
origin
});
}
}
if
(
site
)
{
return
gadget
.
redirect
({
command
:
"
row
"
,
url
:
site
});
}
// User entered wrong password ?
// Notify
return
gadget
.
notifySubmitted
({
message
:
'
Unauthorized storage access
'
,
status
:
'
error
'
})
.
push
(
function
()
{
return
gadget
.
redirect
({
command
:
'
display
'
,
options
:
{
page
:
'
ojs_configurator
'
}});
});
}
// jIO call wrapper for redirection to authentication page if needed
// jIO call wrapper for redirection to authentication page if needed
function
wrapJioCall
(
gadget
,
method_name
,
argument_list
)
{
function
wrapJioCall
(
gadget
,
method_name
,
argument_list
)
{
var
storage
=
gadget
.
state_parameter_dict
.
jio_storage
;
var
storage
=
gadget
.
state_parameter_dict
.
jio_storage
;
...
@@ -13,51 +61,7 @@
...
@@ -13,51 +61,7 @@
return
storage
[
method_name
].
apply
(
storage
,
argument_list
)
return
storage
[
method_name
].
apply
(
storage
,
argument_list
)
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
401
))
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
401
))
{
var
regexp
,
return
redirectToLogin
(
gadget
,
error
);
site
,
login_page
;
if
(
gadget
.
state_parameter_dict
.
jio_storage_name
===
"
ERP5
"
)
{
regexp
=
/^X-Delegate uri=
\"(
http
[
s
]?
:
\/\/[\/\-\[\]
{}()*+=:?&.,
\\\^
$|#
\s\w
%
]
+
)\"
$/
;
login_page
=
error
.
target
.
getResponseHeader
(
'
WWW-Authenticate
'
);
if
(
regexp
.
test
(
login_page
))
{
return
gadget
.
getUrlFor
({
command
:
'
login
'
,
absolute_url
:
true
})
.
push
(
function
(
came_from
)
{
return
gadget
.
redirect
({
command
:
'
raw
'
,
options
:
{
url
:
UriTemplate
.
parse
(
regexp
.
exec
(
login_page
)[
1
])
.
expand
({
came_from
:
came_from
})
}
});
});
}
}
if
(
gadget
.
state_parameter_dict
.
jio_storage_name
===
"
DAV
"
)
{
regexp
=
/^Nayookie login_url=
(
http
[
s
]?
:
\/\/[\/\-\[\]
{}()*+=:?&.,
\\\^
$|#
\s\w
%
]
+
)
$/
;
login_page
=
error
.
target
.
getResponseHeader
(
'
WWW-Authenticate
'
);
if
(
regexp
.
test
(
login_page
))
{
site
=
UriTemplate
.
parse
(
regexp
.
exec
(
login_page
)[
1
]
).
expand
({
back_url
:
window
.
location
.
href
,
origin
:
window
.
location
.
origin
});
}
}
if
(
site
)
{
return
gadget
.
redirect
({
command
:
"
row
"
,
url
:
site
});
}
// User entered wrong password ?
// Notify
return
gadget
.
notifySubmitted
({
message
:
'
Unauthorized storage access
'
,
status
:
'
error
'
})
.
push
(
function
()
{
return
gadget
.
redirect
({
command
:
'
display
'
,
options
:
{
page
:
'
ojs_configurator
'
}});
});
}
}
throw
error
;
throw
error
;
});
});
...
@@ -188,6 +192,7 @@
...
@@ -188,6 +192,7 @@
}
}
if
(
result_list
[
0
]
===
undefined
)
{
return
;
}
if
(
result_list
[
0
]
===
undefined
)
{
return
;
}
if
(
result_list
[
1
]
===
undefined
)
{
return
;
}
if
(
result_list
[
1
]
===
undefined
)
{
return
;
}
gadget
.
state_parameter_dict
.
jio_storage_name
=
result_list
[
1
];
appcache_storage
=
jIO
.
createJIO
(
jio_appchache_options
);
appcache_storage
=
jIO
.
createJIO
(
jio_appchache_options
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
...
@@ -200,14 +205,11 @@
...
@@ -200,14 +205,11 @@
}
}
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
"
Error while appcache-local
"
+
console
.
log
(
"
Error while appcache-local storage synchronization
"
);
"
storage synchronization
"
);
if
(
error
&&
error
.
currentTarget
&&
if
(
error
&&
error
.
currentTarget
&&
error
.
currentTarget
.
status
===
401
)
{
error
.
currentTarget
.
status
===
401
)
{
console
.
log
(
"
Unauthorized access to storage,
"
+
console
.
log
(
"
Unauthorized access to storage, sync cancelled
"
);
"
sync cancelled
"
);
return
redirectToLogin
(
gadget
,
error
);
gadget
.
state_parameter_dict
.
jio_storage_name
=
"
ERP5
"
;
return
;
}
}
console
.
log
(
error
);
console
.
log
(
error
);
throw
error
;
throw
error
;
...
...
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