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 saveObjCWithLoadAfterwards:
true
completion:^(NSError * error) {
if
(error == FALSE)
{
//do nothing
}
}];
Swift
var visitor= Visitor()
visitor.firstName =
"John"
visitor.lastName =
"Doe"
visitor.aomFirstName =
"John"
visitor.aomLastName =
"Doe"
visitor.isGuest = 1
visitor.company =
"Wayne Enterprise"
visitor.save { (error) in
if
error == nil {
//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);
TypeScript
const visitor =
new
Visitor();
visitor.firstName =
"John"
;
visitor.lastName =
"Doe"
;
visitor.aomFirstName =
"John"
;
visitor.aomLastName =
"Doe"
;
visitor.isGuest =
"1"
;
visitor.company =
"XYZ Enterprise"
;
await visitor.save();
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
UserAction *userAction = [UserAction
new
];
[userAction setFirstName:@
"John"
];
[userAction setLastName:@
"Doe"
];
[userAction setAction:@
"login"
];
[userAction saveObjCWithLoadAfterwards:
true
completion:^(NSError * error) {
if
(error == FALSE)
{
}
}];
Swift
var userAction = UserAction()
userAction.firstName =
"John"
userAction.lastName:@
"Doe"
userAction.action =
"login"
userAction.save { (error) in
if
error == nil {
}
}
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);
TypeScript
const userAction =
new
UserAction();
userAction.firstName =
"John"
;
userAction.lastName =
"Doe"
;
userAction.action =
"login"
;
await userAction.save();
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
UserAction *userAction = [UserAction
new
];
[userAction setFirstName:@
"John"
];
[userAction setLastName:@
"Doe"
];
[userAction setAction:@
"logout"
];
[userAction saveObjCWithLoadAfterwards:
true
completion:^(NSError * error) {
if
(error == FALSE)
{
}
}];
Swift
var userAction = UserAction()
userAction.firstName =
"John"
userAction.lastName = "Doe
userAction.action =
"logout"
userAction.save { (error) in
if
error == nil {
}
}
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);
TypeScript
const userAction =
new
UserAction();
userAction.firstName =
"John"
;
userAction.lastName =
"Doe"
;
userAction.action =
"logout"
;
await userAction.save();
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.