MIFOSX-395: provide optional staffId and staffDisplayName to auth response.
This commit is contained in:
+52
-17
@@ -90,7 +90,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="page-wrapper">
|
<div id="page-wrapper">
|
||||||
<div id="flybar">
|
<div id="flybar">
|
||||||
<div id="nav-logo">1.2.0.RELEASE API</div>
|
<div id="nav-logo">1.3.0.RELEASE API</div>
|
||||||
<div class="flybar-nav">
|
<div class="flybar-nav">
|
||||||
<h2 class="flybar-button">Overview</h2>
|
<h2 class="flybar-button">Overview</h2>
|
||||||
<div class="flybar-menu-overview">
|
<div class="flybar-menu-overview">
|
||||||
@@ -12720,8 +12720,7 @@ GET https://DomainName/api/v1/runreports/{reportName}
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a id="authenticate_request" name="authenticate_request"
|
<a id="authenticate_request" name="authenticate_request" class="old-syle-anchor"> </a>
|
||||||
class="old-syle-anchor"> </a>
|
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
<div class="method-description">
|
<div class="method-description">
|
||||||
<h4>Verify authentication</h4>
|
<h4>Verify authentication</h4>
|
||||||
@@ -12736,24 +12735,60 @@ POST authentication?username=mifos&password=password
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
No Request Body
|
No Request Body
|
||||||
</code>
|
</code>
|
||||||
|
<p>Example response of autentication for user that is not linked with any staff.</p>
|
||||||
<code class="method-response">
|
<code class="method-response">
|
||||||
{
|
{
|
||||||
"username": "mifos",
|
"username": "mifos",
|
||||||
"userId": 1,
|
"userId": 1,
|
||||||
"base64EncodedAuthenticationKey": "bWlmb3M6cGFzc3dvcmQ=",
|
"base64EncodedAuthenticationKey": "bWlmb3M6cGFzc3dvcmQ=",
|
||||||
"authenticated": true,
|
"authenticated": true,
|
||||||
"roles": [
|
"officeId": 1,
|
||||||
{
|
"officeName": "Head Office",
|
||||||
"id": 1,
|
"roles": [
|
||||||
"name": "Super user",
|
{
|
||||||
"description": "This role provides all application permissions."
|
"id": 1,
|
||||||
}
|
"name": "Super user",
|
||||||
],
|
"description": "This role provides all application permissions."
|
||||||
"permissions": [
|
}
|
||||||
"ALL_FUNCTIONS"
|
],
|
||||||
]
|
"permissions": [
|
||||||
|
"ALL_FUNCTIONS"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
|
<p>Example response of autentication for user that is linked with a staff member and role.</p>
|
||||||
|
<code class="method-response">
|
||||||
|
{
|
||||||
|
"username": "mifos",
|
||||||
|
"userId": 1,
|
||||||
|
"base64EncodedAuthenticationKey": "bWlmb3M6cGFzc3dvcmQ=",
|
||||||
|
"authenticated": true,
|
||||||
|
"officeId": 1,
|
||||||
|
"officeName": "Head Office",
|
||||||
|
"staffId": 1,
|
||||||
|
"staffDisplayName": "Director, Program",
|
||||||
|
"organisationalRole": {
|
||||||
|
"id": 100,
|
||||||
|
"code": "staffOrganisationalRoleType.programDirector",
|
||||||
|
"value": "Program Director"
|
||||||
|
},
|
||||||
|
"roles": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Super user",
|
||||||
|
"description": "This role provides all application permissions."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permissions": [
|
||||||
|
"ALL_FUNCTIONS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<code class="method-request">
|
<code class="method-request">
|
||||||
POST authentication?username=mifos&password=fail
|
POST authentication?username=mifos&password=fail
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|||||||
+6
-1
@@ -76,9 +76,14 @@ public class AuthenticationApiResource {
|
|||||||
|
|
||||||
final Long officeId = principal.getOffice().getId();
|
final Long officeId = principal.getOffice().getId();
|
||||||
final String officeName = principal.getOffice().getName();
|
final String officeName = principal.getOffice().getName();
|
||||||
|
|
||||||
|
final Long staffId = principal.getStaffId();
|
||||||
|
final String staffDisplayName = principal.getStaffDisplayName();
|
||||||
|
|
||||||
final EnumOptionData organisationalRole = principal.organisationalRoleData();
|
final EnumOptionData organisationalRole = principal.organisationalRoleData();
|
||||||
|
|
||||||
authenticatedUserData = new AuthenticatedUserData(username, officeId, officeName, organisationalRole, roles, permissions,
|
authenticatedUserData = new AuthenticatedUserData(username, officeId, officeName, staffId, staffDisplayName,
|
||||||
|
organisationalRole, roles, permissions,
|
||||||
principal.getId(), new String(base64EncodedAuthenticationKey));
|
principal.getId(), new String(base64EncodedAuthenticationKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-3
@@ -28,6 +28,10 @@ public class AuthenticatedUserData {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String officeName;
|
private final String officeName;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
private final Long staffId;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final String staffDisplayName;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final EnumOptionData organisationalRole;
|
private final EnumOptionData organisationalRole;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Collection<RoleData> roles;
|
private final Collection<RoleData> roles;
|
||||||
@@ -41,17 +45,21 @@ public class AuthenticatedUserData {
|
|||||||
this.authenticated = false;
|
this.authenticated = false;
|
||||||
this.officeId = null;
|
this.officeId = null;
|
||||||
this.officeName = null;
|
this.officeName = null;
|
||||||
|
this.staffId = null;
|
||||||
|
this.staffDisplayName = null;
|
||||||
this.organisationalRole = null;
|
this.organisationalRole = null;
|
||||||
this.roles = null;
|
this.roles = null;
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticatedUserData(final String username, final Long officeId, final String officeName,
|
public AuthenticatedUserData(final String username, final Long officeId, final String officeName, final Long staffId,
|
||||||
final EnumOptionData organisationalRole, final Collection<RoleData> roles, final Collection<String> permissions,
|
final String staffDisplayName, final EnumOptionData organisationalRole, final Collection<RoleData> roles,
|
||||||
final Long userId, final String base64EncodedAuthenticationKey) {
|
final Collection<String> permissions, final Long userId, final String base64EncodedAuthenticationKey) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = officeName;
|
this.officeName = officeName;
|
||||||
|
this.staffId = staffId;
|
||||||
|
this.staffDisplayName = staffDisplayName;
|
||||||
this.organisationalRole = organisationalRole;
|
this.organisationalRole = organisationalRole;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
|
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
|
||||||
|
|||||||
+5
-1
@@ -31,7 +31,6 @@ public class Staff extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "lastname", length = 50)
|
@Column(name = "lastname", length = 50)
|
||||||
private String lastname;
|
private String lastname;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Column(name = "display_name", length = 100)
|
@Column(name = "display_name", length = 100)
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
|
||||||
@@ -47,6 +46,7 @@ public class Staff extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "organisational_role_enum", nullable = true)
|
@Column(name = "organisational_role_enum", nullable = true)
|
||||||
private Integer organisationalRoleType;
|
private Integer organisationalRoleType;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "organisational_role_parent_staff_id", nullable = true)
|
@JoinColumn(name = "organisational_role_parent_staff_id", nullable = true)
|
||||||
private Staff organisationalRoleParentStaff;
|
private Staff organisationalRoleParentStaff;
|
||||||
@@ -158,4 +158,8 @@ public class Staff extends AbstractPersistable<Long> {
|
|||||||
public Long officeId() {
|
public Long officeId() {
|
||||||
return this.office.getId();
|
return this.office.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String displayName() {
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+16
@@ -465,4 +465,20 @@ public class AppUser extends AbstractPersistable<Long> implements PlatformUser {
|
|||||||
if (hasNotPermissionForDatatable(datatable, "READ")) { throw new NoAuthorizationException("Not authorised to read datatable: "
|
if (hasNotPermissionForDatatable(datatable, "READ")) { throw new NoAuthorizationException("Not authorised to read datatable: "
|
||||||
+ datatable); }
|
+ datatable); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getStaffId() {
|
||||||
|
Long staffId = null;
|
||||||
|
if (this.staff != null) {
|
||||||
|
staffId = this.staff.getId();
|
||||||
|
}
|
||||||
|
return staffId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStaffDisplayName() {
|
||||||
|
String staffDisplayName = null;
|
||||||
|
if (this.staff != null) {
|
||||||
|
staffDisplayName = this.staff.displayName();
|
||||||
|
}
|
||||||
|
return staffDisplayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user