Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
frontend-auth
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
32ce5518
authored
2016-08-05 16:28:35 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add some code to wrap the Backbone.sync method, to add ?sessionId to a
url.
1 parent
a6367ec8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
src/scripts/Auth.js
src/scripts/Auth.js
View file @
32ce551
...
...
@@ -32,6 +32,19 @@ define(function(require) {
return
deferred
;
}
var
authSync
=
function
authSync
(
origSync
,
method
,
model
,
options
)
{
var
args
=
_
.
toArray
(
arguments
);
args
.
shift
();
var
url
=
options
.
url
||
_
.
result
(
model
,
'url'
);
if
(
url
)
{
var
sessionId
=
app
.
get
(
'auth'
).
get
(
'sessionId'
);
if
(
sessionId
)
{
options
.
url
=
url
+
(
url
.
indexOf
(
'?'
)
==
-
1
?
'?'
:
'&'
)
+
'sessionId='
+
sessionId
;
}
}
return
origSync
.
apply
(
this
,
args
);
};
var
FacebookProvider
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
data
,
globalOptions
)
{
// early facebook javascript load
...
...
@@ -255,6 +268,15 @@ define(function(require) {
},
{
FacebookProvider
:
FacebookProvider
,
FormProvider
:
FormProvider
,
wrapSync
:
function
(
origSync
)
{
return
function
()
{
return
authSync
.
apply
(
this
,
[
origSync
].
concat
(
_
.
toArray
(
arguments
)));
};
},
syncMixin
:
function
(
Class
)
{
Class
.
prototype
.
sync
=
Auth
.
wrapSync
(
Class
.
prototype
.
sync
);
return
Class
;
},
});
return
Auth
;
});
...
...
Please
register
or
sign in
to post a comment