Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
nexedi
ecommerce-ui
Commits
d4add8a8
Commit
d4add8a8
authored
Mar 28, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app: removed all client-side login code until needed
parent
1751ac65
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
321 deletions
+66
-321
data/global.json
data/global.json
+0
-61
js/erp5_loader.js
js/erp5_loader.js
+66
-260
No files found.
data/global.json
View file @
d4add8a8
[
{
"type"
:
"hello"
,
"set_on"
:
"login_dict"
,
"modernizr"
:
[
"localStorage"
],
"property_dict"
:
{
"use_login"
:
true
},
"scheme"
:
[{
"property_dict"
:
{
"google"
:
"1028374738607-pg2qqcopjpoc09shlpul3mehu2dv76ln.apps.googleusercontent.com"
}
}],
"children"
:
[]
},
{
"type"
:
"i18n"
,
"set_on"
:
"lang_dict"
,
...
...
@@ -33,53 +19,6 @@
}],
"children"
:
[]
},
{
"type"
:
"StateMachine"
,
"set_on"
:
"state_dict"
,
"scheme"
:
[{
"set_name"
:
"sync_status"
,
"property_dict"
:
{
"initial"
:
"diverge"
,
"events"
:
[
{
"name"
:
"diverge"
,
"from"
:
"insync"
,
"to"
:
"async"
},
{
"name"
:
"harmonize"
,
"from"
:
"async"
,
"to"
:
"insync"
}
]
}
},
{
"set_name"
:
"login_status"
,
"property_dict"
:
{
"initial"
:
"logout"
,
"events"
:
[
{
"name"
:
"login"
,
"from"
:
"logged_out"
,
"to"
:
"logged_in"
},
{
"name"
:
"logout"
,
"from"
:
"logged_in"
,
"to"
:
"logged_out"
}
]
}
},
{
"set_name"
:
"connection_status"
,
"property_dict"
:
{
"initial"
:
"loss_connection"
,
"events"
:
[
{
"name"
:
"force_online"
,
"from"
:
[
"probing"
,
"disconnected"
,
"online"
],
"to"
:
"offline"
},
{
"name"
:
"force_online"
,
"from"
:
[
"disconnected"
,
"offline"
],
"to"
:
"probing"
},
{
"name"
:
"loss_connection"
,
"from"
:
[
"online"
,
"offline"
,
"disconnected"
],
"to"
:
"probing"
},
{
"name"
:
"found_connection"
,
"from"
:
"probing"
,
"to"
:
"online"
}
]
}
}],
"children"
:
[
{
"generate"
:
"widget"
,
"type"
:
"crumbs"
,
"children"
:
[
{
"href"
:
"#"
,
"text"
:
"Synchronization"
,
"text_i18n"
:
"global_dict.sync_status"
,
"icon"
:
"random"
,
"info"
:
"sync_status"
},
{
"href"
:
"#"
,
"text"
:
"Login"
,
"text_i18n"
:
"global_dict.login_status"
,
"icon"
:
"user"
,
"info"
:
"login_status"
},
{
"href"
:
"#"
,
"text"
:
"Connection"
,
"text_i18n"
:
"global_dict.connection_status"
,
"icon"
:
"signal"
,
"info"
:
"connection_status"
}
]
}
]
},
{
"type"
:
"status_dict"
,
"property_dict"
:
{
...
...
js/erp5_loader.js
View file @
d4add8a8
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true, todo: true */
/*global console, window, jIO, complex_queries, FormData, RSVP, document,
jQuery, i18n,
hello,
Recaptcha, XMLHttpRequest, Modernizr */
jQuery, i18n, Recaptcha, XMLHttpRequest, Modernizr */
(
function
(
window
,
document
,
$
)
{
"
use strict
"
;
...
...
@@ -3071,15 +3071,6 @@
factory
.
util
.
setPopupPointer
(
obj
,
"
tasks
"
);
},
/**
* Show application popup
* @method login
* @param {object} obj Action Object
**/
"
login
"
:
function
(
obj
)
{
factory
.
util
.
setPopupPointer
(
obj
,
"
login
"
);
},
/**
* Show export popup
* @method export
...
...
@@ -4676,151 +4667,6 @@
}
};
/**
* Update login status
* @method updateLoginStatus
* @param {object} response Object initiating the status update
* @param {string} portal_type Portal Type concerned
**/
app
.
setLoginStatus
=
function
(
response
)
{
var
stamp
,
provider
,
auth
,
links
,
i
,
login
;
stamp
=
Date
.
now
();
provider
=
response
.
network
?
response
.
network
.
slice
(
0
,
2
)
:
"
self
"
;
auth
=
response
.
authResponse
;
if
(
flux
.
state
===
undefined
)
{
flux
.
state
=
{};
}
// store in flux
flux
.
state
[
provider
]
=
{
"
token
"
:
auth
?
auth
.
access_token
:
response
.
id
,
"
issued
"
:
stamp
,
"
expires
"
:
auth
?
auth
.
expires_in
:
3600
};
// need to update the .... button
// TODO: make a login gadget, store dependend buttons in state
links
=
util
.
getHeader
().
getElementsByTagName
(
"
A
"
);
for
(
i
=
0
;
i
<
links
.
length
;
i
+=
1
)
{
if
(
links
[
i
].
getAttribute
(
"
data-depend
"
)
===
"
login_state
"
)
{
login
=
links
[
i
];
login
.
parentNode
.
replaceChild
(
factory
.
util
.
convertDict
(
undefined
,
"
logoff
"
,
true
),
login
);
}
}
};
/**
* Check if a login status is still valid
* @method checkLoginStatus
* @param {boolean} skip Return out
* @param {object} pass Passed information to be returned
* @return {boolean} true/false
**/
// TODO: make this work with a regular login, too!!!
// TODO: refactor, make sure we always pass a pass!
app
.
checkLoginStatus
=
function
(
skip
,
pass
)
{
var
state
,
logger
,
provider
,
verify
,
url
,
signee
,
valid
,
auth_config
,
stamp
,
expires
,
auth_response
;
if
(
skip
===
undefined
)
{
// TODO: name collusion! make normal pass object!
return
RSVP
.
resolve
({
"
pass
"
:
skip
});
}
logger
=
app
.
state_dict
.
login_pointer
;
verify
=
app
.
state_dict
.
verification_dict
;
if
(
logger
)
{
// try flux
state
=
flux
.
state
;
// found state
// TODO: break once first active session is found! For now I would
// like to keep one active login only.
// TODO: don't hardcode GOOGLE here...
if
(
state
)
{
for
(
provider
in
state
)
{
if
(
state
.
hasOwnProperty
(
provider
))
{
auth_config
=
state
[
provider
];
stamp
=
Date
.
now
();
// assemble url
switch
(
provider
)
{
case
"
go
"
:
url
=
verify
.
google
+
auth_config
.
token
;
signee
=
"
google
"
;
break
;
case
"
self
"
:
url
=
undefined
;
signee
=
"
self
"
;
break
;
}
// test for timeout
if
(
auth_config
.
issued
&&
auth_config
.
expires
)
{
expires
=
auth_config
.
issued
+
(
auth_config
.
expires
*
1000
);
if
(
expires
>
stamp
)
{
valid
=
true
;
}
else
{
delete
state
[
provider
];
}
}
}
}
}
// token in memory still valid, add it to the pass object and done
if
(
valid
)
{
if
(
pass
)
{
pass
.
active_login
=
true
;
pass
.
verified_by
=
signee
;
pass
.
token
=
auth_config
.
token
;
pass
.
expires_in
=
expires
;
return
RSVP
.
resolve
(
pass
);
}
return
RSVP
.
resolve
({
"
expires_in
"
:
expires
});
}
// if we have a url, we have an access token, check if it's valid
if
(
url
)
{
return
util
.
ajax
({
"
url
"
:
url
})
.
then
(
function
(
answer
)
{
auth_response
=
util
.
parse
(
answer
.
target
.
response
);
if
(
pass
)
{
pass
.
active_login
=
true
;
pass
.
verified_by
=
signee
;
pass
.
token
=
auth_config
.
token
;
pass
.
expires_in
=
auth_response
.
expires_in
;
return
RSVP
.
resolve
(
pass
);
}
return
auth_response
;
})
.
fail
(
function
(
event
)
{
// invalid session > return 400, so we are back on the then-column
if
(
event
.
target
.
status
===
400
)
{
auth_response
=
util
.
parse
(
event
.
target
.
response
);
if
(
pass
)
{
return
RSVP
.
resolve
(
pass
);
}
return
RSVP
.
resolve
(
pass
);
}
throw
util
.
parse
(
event
.
target
);
});
}
// TODO: this should ask to login again!
if
(
pass
)
{
pass
.
active_login
=
false
;
return
RSVP
.
resolve
(
pass
);
}
return
RSVP
.
resolve
(
"
no state found/not logged in
"
);
}
app
.
util
.
error
(
"
loginStatus: Missing login handler.
"
);
};
/**
* Update info fields (field displaying some sort of information
* @method "
...
...
@@ -5831,7 +5677,6 @@
pass
=
{
"
content_dict
"
:
content_dict
||
{},
"
url_dict
"
:
url_dict
||
{},
"
auth_dict
"
:
{},
"
data_dict
"
:
{},
"
create
"
:
create
,
"
purge
"
:
purge
...
...
@@ -5851,7 +5696,6 @@
app
.
storage_dict
.
property_dict
.
name_dict
.
configuration
,
"
pass
"
:
pass
})
.
then
(
app
.
content
.
testAuth
)
.
then
(
app
.
content
.
fields
)
.
then
(
app
.
content
.
total
)
.
then
(
app
.
content
.
query
)
...
...
@@ -5860,42 +5704,6 @@
};
/**
* Set and test authentication
* @method testAuth
* @param {object} reply Pass through object and reply (gadget config)
* @return {object} object
**/
app
.
content
.
testAuth
=
function
(
reply
)
{
var
pass
=
reply
.
pass
;
if
(
!
pass
.
skip
)
{
// (dynamic element) config_dict
pass
.
config_dict
=
util
.
parse
(
reply
.
response
);
// auth_dict
if
(
app
.
state_dict
.
login
)
{
pass
.
auth_dict
.
auth
=
pass
.
config_dict
.
property_dict
.
requires_authentication
;
// test auth
if
(
pass
.
auth_dict
.
auth
)
{
return
app
.
checkLoginStatus
(
true
,
pass
)
.
then
(
function
(
new_pass
)
{
return
{
"
pass
"
:
new_pass
};
})
.
fail
(
app
.
util
.
error
);
}
}
}
return
{
"
pass
"
:
pass
};
};
/**
* Load field definitions if necessary
* @method fields
...
...
@@ -5907,8 +5715,11 @@
if
(
!
pass
.
skip
)
{
// (dynamic element) config_dict
pass
.
config_dict
=
util
.
parse
(
reply
.
response
);
// determine access
pass
.
grant
=
pass
.
auth_dict
.
active_login
||
!
pass
.
auth_dict
.
auth
;
pass
.
grant
=
true
;
// fetch field definitions
if
((
pass
.
grant
||
pass
.
mode
===
"
new
"
)
&&
...
...
@@ -6177,10 +5988,6 @@
pointer_results
=
{
"
data
"
:
{
"
total_rows
"
:
1
,
"
rows
"
:
[{
"
doc
"
:
{}}]}};
}
// set content to display or pass template to dynamic child
if
(
pointer_results
===
null
)
{
quirk_dict
.
no_show
=
app
.
login_dict
.
property_dict
.
no_auth
;
}
else
{
// inherit item id, so it's available in form as indentifier
if
(
pointer_results
.
data
.
total_rows
===
1
)
{
quirk_dict
.
data
=
{
"
_id
"
:
pointer_results
.
data
.
rows
[
0
].
doc
.
_id
};
...
...
@@ -6251,7 +6058,6 @@
}
}
}
}
// loop over children
if
(
kids
.
length
)
{
...
...
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