Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
0c06349f
Commit
0c06349f
authored
Jul 14, 2015
by
BigBlueHat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decaf config/accounts.js
parent
984a745a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
77 deletions
+87
-77
accounts.coffee
h/static/scripts/config/accounts.coffee
+0
-77
accounts.js
h/static/scripts/config/accounts.js
+87
-0
No files found.
h/static/scripts/config/accounts.coffee
deleted
100644 → 0
View file @
984a745a
angular
=
require
(
'angular'
)
SESSION_ACTIONS
=
[
'login'
'logout'
'register'
'forgot_password'
'reset_password'
'edit_profile'
'disable_user'
]
configure
=
[
'$httpProvider'
,
'identityProvider'
,
'sessionProvider'
(
$httpProvider
,
identityProvider
,
sessionProvider
)
->
# Pending authentication check
authCheck
=
null
# Use the Pyramid XSRF header name
$httpProvider
.
defaults
.
xsrfHeaderName
=
'X-CSRF-Token'
identityProvider
.
checkAuthentication
=
[
'$q'
,
'session'
,
(
$q
,
session
)
->
(
authCheck
=
$q
.
defer
()).
promise
.
then
do
->
session
.
load
().
$promise
.
then
(
data
)
->
if
data
.
userid
then
authCheck
.
resolve
data
.
csrf
else
authCheck
.
reject
'no session'
,
->
authCheck
.
reject
'request failure'
]
identityProvider
.
forgetAuthentication
=
[
'$q'
,
'flash'
,
'session'
,
(
$q
,
flash
,
session
)
->
session
.
logout
({}).
$promise
.
then
->
authCheck
=
$q
.
defer
()
authCheck
.
reject
'no session'
return
null
.
catch
(
err
)
->
flash
.
error
(
'Sign out failed!'
)
throw
err
]
identityProvider
.
requestAuthentication
=
[
'$q'
,
'$rootScope'
,
(
$q
,
$rootScope
)
->
authCheck
.
promise
.
catch
->
(
authRequest
=
$q
.
defer
()).
promise
.
finally
do
->
$rootScope
.
$on
'auth'
,
(
event
,
err
,
data
)
->
if
err
then
authRequest
.
reject
err
else
authRequest
.
resolve
data
.
csrf
]
sessionProvider
.
actions
.
load
=
method
:
'GET'
withCredentials
:
true
sessionProvider
.
actions
.
profile
=
method
:
'GET'
params
:
__formid__
:
'profile'
withCredentials
:
true
for
action
in
SESSION_ACTIONS
sessionProvider
.
actions
[
action
]
=
method
:
'POST'
params
:
__formid__
:
action
withCredentials
:
true
]
angular
.
module
(
'h'
)
.
value
(
'xsrf'
,
token
:
null
)
.
config
(
configure
)
h/static/scripts/config/accounts.js
0 → 100644
View file @
0c06349f
var
angular
=
require
(
'angular'
);
var
SESSION_ACTIONS
=
[
'login'
,
'logout'
,
'register'
,
'forgot_password'
,
'reset_password'
,
'edit_profile'
,
'disable_user'
];
var
configure
=
[
'$httpProvider'
,
'identityProvider'
,
'sessionProvider'
,
function
(
$httpProvider
,
identityProvider
,
sessionProvider
)
{
var
action
;
var
authCheck
;
authCheck
=
null
;
$httpProvider
.
defaults
.
xsrfHeaderName
=
'X-CSRF-Token'
;
identityProvider
.
checkAuthentication
=
[
'$q'
,
'session'
,
function
(
$q
,
session
)
{
return
(
authCheck
=
$q
.
defer
()).
promise
.
then
((
function
()
{
return
session
.
load
().
$promise
.
then
(
function
(
data
)
{
if
(
data
.
userid
)
{
return
authCheck
.
resolve
(
data
.
csrf
);
}
else
{
return
authCheck
.
reject
(
'no session'
);
}
},
function
()
{
return
authCheck
.
reject
(
'request failure'
);
});
})());
}
];
identityProvider
.
forgetAuthentication
=
[
'$q'
,
'flash'
,
'session'
,
function
(
$q
,
flash
,
session
)
{
return
session
.
logout
({}).
$promise
.
then
(
function
()
{
authCheck
=
$q
.
defer
();
authCheck
.
reject
(
'no session'
);
return
null
;
}).
catch
(
function
(
err
)
{
flash
.
error
(
'Sign out failed!'
);
throw
err
;
});
}
];
identityProvider
.
requestAuthentication
=
[
'$q'
,
'$rootScope'
,
function
(
$q
,
$rootScope
)
{
return
authCheck
.
promise
.
catch
(
function
()
{
var
authRequest
;
return
(
authRequest
=
$q
.
defer
()).
promise
.
finally
((
function
()
{
return
$rootScope
.
$on
(
'auth'
,
function
(
event
,
err
,
data
)
{
if
(
err
)
{
return
authRequest
.
reject
(
err
);
}
else
{
return
authRequest
.
resolve
(
data
.
csrf
);
}
});
})());
});
}
];
sessionProvider
.
actions
.
load
=
{
method
:
'GET'
,
withCredentials
:
true
};
sessionProvider
.
actions
.
profile
=
{
method
:
'GET'
,
params
:
{
__formid__
:
'profile'
},
withCredentials
:
true
};
var
results
=
[];
for
(
var
i
=
0
;
i
<
SESSION_ACTIONS
.
length
;
i
++
)
{
action
=
SESSION_ACTIONS
[
i
];
results
.
push
(
sessionProvider
.
actions
[
action
]
=
{
method
:
'POST'
,
params
:
{
__formid__
:
action
},
withCredentials
:
true
});
}
return
results
;
}
];
angular
.
module
(
'h'
).
value
(
'xsrf'
,
{
token
:
null
}).
config
(
configure
);
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