. . .

Access Control Module

The Access Control Module lets app developers to log visitors in or out. In the future, these visitors (or employees) will also be synced with LDAP.

Configuration

No special configuration is required.

Usage

The Access Control Module provides the class userAction. This class is used to log a visitor in or out. During this process, a time stamp is created automatically.

First, add a visitor named "John Doe".

Android
Visitor visitor = new Visitor();
visitor.setFirstName("John");
visitor.setLastName("Doe");
visitor.setAomFirstName("John");
visitor.setAomLastName("Doe");
visitor.setIsGuest(0L);
visitor.setCompany("Wayne Enterprise");
visitor.saveAsync(...);
Objective-C
Visitor *visitor= [Visitor new];
[visitor setFirstName:@"John"];
[visitor setLastName:@"Doe"];
[visitor setAomFirstName:@"John"];
[visitor setAomLastName:@"Doe"];
[visitor setIsGuest:1];
[visitor setCompany:@"Wayne Enterprise"];
[visitor saveAsyncWithBlock:^(NSError *error) {
if(error == FALSE)
{
//do nothing
}
}];

JavaScript
var visitor=new Apiomat.Visitor();
visitor.setFirstName("John");
visitor.setLastName("Doe");
visitor.setAomFirstName("John");
visitor.setAomLastName("Doe");
visitor.setIsGuest("1");
visitor.setCompany("Wayne Enterprise");
var saveCB= {
onOk:function () {
console.log("Visitor saved");
},
onError:function(error) {
console.log(error);
}
};
visitor.save(saveCB);

Now we will log the visitor in.

Android
UserAction userAction = new UserAction();
userAction.setFirstName("John");
userAction.setLastName("Doe");
userAction.setAction("login");
userAction.saveAsync(...);
Objective-C
Message *userAction = [UserAction new];
[userAction setFirstName:@"John"];
[userAction setLastName:@"Doe"];
[userAction setAction:@"login"];
[userAction saveAsyncWithBlock:^(NSError *error) {
if(error == FALSE)
{
}
}];

JavaScript
var userAction=new Apiomat.UserAction();
userAction.setFirstName("John");
userAction.setLastName("Doe");
userAction.setAction("login");
var saveCB= {
onOk:function () {
console.log("Visitor logged in");
},
onError:function(error) {
console.log(error);
}
};
userAction.save(saveCB);

When the visitor (John Doe) leaves the office, we will log him out.

Android
UserAction userAction = new UserAction();
userAction.setFirstName("John");
userAction.setLastName("Doe");
userAction.setAction("logout");
userAction.saveAsync(...);
Objective-C
Message *userAction = [UserAction new];
[userAction setFirstName:@"John"];
[userAction setLastName:@"Doe"];
[userAction setAction:@"logout"];
[userAction saveAsyncWithBlock:^(NSError *error) {
if(error == FALSE)
{
}
}];

JavaScript
var userAction=new Apiomat.UserAction();
userAction.setFirstName("John");
userAction.setLastName("Doe");
userAction.setAction("logout");
var saveCB= {
onOk:function () {
console.log("Visitor logged out");
},
onError:function(error) {
console.log(error);
}
};
userAction.save(saveCB);

The visitor's timestamp object is updated after logging in and logging out.

{
"@type": "AccessControl$Timestamp",
"createdAt": 1497967202285,
"lastModifiedAt": 1497970912116,
"id": "59492a62dc5ecc33c19dacd5",
"applicationName": "AccessControl",
"moduleName": "AccessControl",
"allowedRolesRead": [],
"allowedRolesWrite": [],
"allowedRolesGrant": [],
"restrictResourceAccess": false,
"referencedHrefs": {
"visitor": [
"http://localhost/yambas/rest/apps/AccessControl/models/AccessControl/Visitor/594927dedc5ecc33c19dacd1"
]
},
"allowedRolesReadFromClass": [],
"allowedRolesWriteFromClass": [],
"allowedRolesCreateFromClass": [],
"allowedRolesGrantFromClass": [],
"restrictResourceAccessFromClass": false,
"href": "http://localhost/yambas/rest/apps/AccessControl/models/AccessControl/Timestamp/59492a62dc5ecc33c19dacd5",
"allowedRolesReadFromObject": [],
"allowedRolesWriteFromObject": [],
"allowedRolesGrantFromObject": [],
"restrictResourceAccessFromObject": false,
"checkIn": 1497967202286,
"checkOut": 1497970912105,
"diffTimestamp": "1h 1m 49s ",
"diffTimestampHour": 1,
"diffTimestampMinute": 1,
"diffTimestampSecond": 49,
"visitorPlain": "John Doe",
"visitorHref": "http://localhost/yambas/rest/apps/AccessControl/models/AccessControl/Timestamp/59492a62dc5ecc33c19dacd5/visitor"
}

This JSON object is the timestamp, which the checkIn and CheckOut times.