Skip to content

Commit eca3e23

Browse files
committed
add settings control
1 parent 5d7575f commit eca3e23

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

auth.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,65 @@ kidstuff.auth.module.provider('auth',function() {
333333
});
334334
}
335335

336+
337+
auth.updateSettings = function(settings, success, error) {
338+
if(typeof settings != "object") {
339+
return
340+
}
341+
342+
$http({
343+
method: 'PATCH',
344+
url: config.endPoint+'/settings',
345+
headers: {Authorization: 'Bearer '+localStorageService.get('access_token')},
346+
data: settings
347+
}).
348+
success(function(data, status, headers, config) {
349+
if(typeof success == 'function') {
350+
success();
351+
}
352+
}).
353+
error(function(data, status, headers, config) {
354+
if(typeof error == 'function') {
355+
error(data);
356+
}
357+
});
358+
}
359+
360+
auth.getSettings = function(keys, success, error) {
361+
$http({
362+
method: 'GET',
363+
url: config.endPoint+'/settings?keys='+keys.toString(),
364+
headers: {Authorization: 'Bearer '+localStorageService.get('access_token')}
365+
}).
366+
success(function(data, status, headers, config) {
367+
if(typeof success == 'function') {
368+
success(data);
369+
}
370+
}).
371+
error(function(data, status, headers, config) {
372+
if(typeof error == 'function') {
373+
error(data);
374+
}
375+
});
376+
}
377+
378+
auth.removeSettings = function(keys, success, error) {
379+
$http({
380+
method: 'DELETE',
381+
url: config.endPoint+'/settings?keys='+keys.toString(),
382+
headers: {Authorization: 'Bearer '+localStorageService.get('access_token')}
383+
}).
384+
success(function(data, status, headers, config) {
385+
if(typeof success == 'function') {
386+
success();
387+
}
388+
}).
389+
error(function(data, status, headers, config) {
390+
if(typeof error == 'function') {
391+
error(data);
392+
}
393+
});
394+
}
336395
return auth;
337396
}];
338397

0 commit comments

Comments
 (0)