update security handling for user namespace
This commit is contained in:
@@ -110,6 +110,14 @@ function redirect_to(mapping, variables){
|
||||
}
|
||||
window.location = QMobile.root_url() + path_mapping[mapping] + '.html?' + vars.join('&')
|
||||
}
|
||||
function direct_to_site(mapping, variables){
|
||||
variables || (variables = {});
|
||||
var vars = []
|
||||
for(var name in variables){
|
||||
vars.push(name + '=' +variables[name])
|
||||
}
|
||||
window.location = data_host + path_mapping[mapping] + '.html?' + vars.join('&')
|
||||
}
|
||||
function currency(num) {
|
||||
return Qwaiter.currency(num);
|
||||
}
|
||||
@@ -131,9 +139,11 @@ function t(path, vars){
|
||||
return result;
|
||||
}
|
||||
$.ajaxSetup({
|
||||
error: function(xhr, ajaxOptions, error){
|
||||
if(xhr.status == 401 || xhr.status == 0){
|
||||
window.location = data_host + '/user/obtain_token.html';
|
||||
error: function(xhr, ajaxOptions, error, another){
|
||||
if(xhr.status == 401){
|
||||
direct_to_site('obtain_user_token');
|
||||
}else if(xhr.status == 0){
|
||||
QMobile.connection_problem();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,7 +13,9 @@ window.Quser=
|
||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) -> Quser.handle_active_list_default_actions(res))
|
||||
handle_active_list: (callback) ->
|
||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) ->
|
||||
if !res.list_active
|
||||
if(res.ok == false && res.status && res.status == 401)
|
||||
direct_to_site('obtain_user_token')
|
||||
else if !res.list_active
|
||||
redirect_to 'user_root', {list_closed: 'true'}
|
||||
return
|
||||
window.active_list = res
|
||||
@@ -22,6 +24,9 @@ window.Quser=
|
||||
)
|
||||
handle_active_list_default_actions: (response)->
|
||||
response ||= {}
|
||||
if(response.ok == false && response.status && response.status == 401)
|
||||
direct_to_site('obtain_user_token')
|
||||
return
|
||||
if response.table_number
|
||||
$('.table-number').text(response.table_number)
|
||||
if response.supplier_name
|
||||
|
||||
Reference in New Issue
Block a user