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
ef955f89
Commit
ef955f89
authored
May 05, 2015
by
gergely-ujvari
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2210 from hypothesis/client-config
Break out client configuration into a Bundle
parents
d212725d
8a3e15b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
68 deletions
+79
-68
account.coffee
h/static/scripts/account/account.coffee
+2
-67
app.coffee
h/static/scripts/app.coffee
+0
-1
accounts.coffee
h/static/scripts/config/accounts.coffee
+77
-0
No files found.
h/static/scripts/account/account.coffee
View file @
ef955f89
angular
=
require
(
'angular'
)
AUTH_SESSION_ACTIONS
=
[
'login'
'logout'
'register'
'forgot_password'
'reset_password'
'edit_profile'
'disable_user'
]
class
AuthAppController
this
.
$inject
=
[
'$location'
,
'$scope'
,
'$timeout'
,
'$window'
,
'session'
]
...
...
@@ -43,15 +33,10 @@ class AuthPageController
configure
=
[
'$httpProvider'
,
'$locationProvider'
,
'$routeProvider'
,
'identityProvider'
,
'sessionProvider'
'$httpProvider'
,
'$locationProvider'
,
'$routeProvider'
(
$httpProvider
,
$locationProvider
,
$routeProvider
,
identityProvider
,
sessionProvider
$httpProvider
,
$locationProvider
,
$routeProvider
)
->
# Pending authentication check
authCheck
=
null
# Use the Pyramid XSRF header name
$httpProvider
.
defaults
.
xsrfHeaderName
=
'X-CSRF-Token'
...
...
@@ -69,56 +54,6 @@ configure = [
$routeProvider
.
when
'/reset_password/:code?'
,
controller
:
'AuthPageController'
templateUrl
:
'auth.html'
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
AUTH_SESSION_ACTIONS
sessionProvider
.
actions
[
action
]
=
method
:
'POST'
params
:
__formid__
:
action
withCredentials
:
true
]
...
...
h/static/scripts/app.coffee
View file @
ef955f89
...
...
@@ -146,7 +146,6 @@ module.exports = angular.module('h', [
.
service
(
'unicode'
,
require
(
'./unicode'
))
.
service
(
'viewFilter'
,
require
(
'./view-filter'
))
.
value
(
'xsrf'
,
token
:
null
)
.
value
(
'AnnotationSync'
,
require
(
'./annotation-sync'
))
.
value
(
'AnnotationUISync'
,
require
(
'./annotation-ui-sync'
))
.
value
(
'Discovery'
,
require
(
'./discovery'
))
...
...
h/static/scripts/config/accounts.coffee
0 → 100644
View file @
ef955f89
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
)
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