AngularJS client lib for kidstuff/auth REST API
- AngularJS >= 1.2.24
- MomentJS >= 2.5.1
- angular-local-storage
app = angular.module('app', ['kidstuff.auth']);
app.config([authProvider', function(authProvider)
authProvider.setEndPoint('http://example.com/auth');
}]);
isLoged() return boolean
currentUser() return User obejct
login(email string, password string, success callback(data), error callback(error))
Example:
app.controller('LoginController', ['$scope', 'auth', function($scope, auth) {
$scope.user = {};
if(auth.isLoged()) {
// warrning
}
$scope.submit = function() {
auth.login($scope.user.Email, $scope.user.Pwd, function(data) {
// show success message
}, function(err) {
// log error
});
}
}]);
setLoged(token string, expired RFC 3999 string, user_object_)
logout()
getUser(id string, success callback(data), error callback(error))
createUser(userInfo object, success callback(data), error callback(error))
removeUser(userId string, success callback(data), error callback(error))
updateUserProfile(id string, profile object, success callback(data), error callback(error))
updateUserApproval(id string, approve boolean, success callback(data), error callback(error))
listUser(params object, success callback(data), error callback(error))
removeUserGroup(userId string, groupId string, success callback(data), error callback(error))
addUserGroup(userId string, groupId string, success callback(data), error callback(error))
listGroup(params object, success callback(data), error callback(error))
createGroup(group object, success callback(data), error callback(error))
getGroup(id string, success callback(data), error callback(error))
updateGroup(group object, success callback(data), error callback(error))
removeGroup(id string, success callback(data), error callback(error))
updateSettings(settings object, success callback(data), error callback(error))
getSettings(keys array of string, success callback(data), error callback(error))
Example:
keys = ["key1", "key2", "key3"];
auth.getSettings(keys, function(settings) {
// console.log(settings)
// Object {key1: "val1", key2: "val2", key2: "val3"}
}, function(err) {
});
removeSettings(keys array of string, success callback(data), error callback(error))