MIFOSX-395: provide optional staffId and staffDisplayName to auth response.
This commit is contained in:
+6
-1
@@ -76,9 +76,14 @@ public class AuthenticationApiResource {
|
||||
|
||||
final Long officeId = principal.getOffice().getId();
|
||||
final String officeName = principal.getOffice().getName();
|
||||
|
||||
final Long staffId = principal.getStaffId();
|
||||
final String staffDisplayName = principal.getStaffDisplayName();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -28,6 +28,10 @@ public class AuthenticatedUserData {
|
||||
@SuppressWarnings("unused")
|
||||
private final String officeName;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long staffId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String staffDisplayName;
|
||||
@SuppressWarnings("unused")
|
||||
private final EnumOptionData organisationalRole;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<RoleData> roles;
|
||||
@@ -41,17 +45,21 @@ public class AuthenticatedUserData {
|
||||
this.authenticated = false;
|
||||
this.officeId = null;
|
||||
this.officeName = null;
|
||||
this.staffId = null;
|
||||
this.staffDisplayName = null;
|
||||
this.organisationalRole = null;
|
||||
this.roles = null;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public AuthenticatedUserData(final String username, final Long officeId, final String officeName,
|
||||
final EnumOptionData organisationalRole, final Collection<RoleData> roles, final Collection<String> permissions,
|
||||
final Long userId, final String base64EncodedAuthenticationKey) {
|
||||
public AuthenticatedUserData(final String username, final Long officeId, final String officeName, final Long staffId,
|
||||
final String staffDisplayName, final EnumOptionData organisationalRole, final Collection<RoleData> roles,
|
||||
final Collection<String> permissions, final Long userId, final String base64EncodedAuthenticationKey) {
|
||||
this.username = username;
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
this.staffId = staffId;
|
||||
this.staffDisplayName = staffDisplayName;
|
||||
this.organisationalRole = organisationalRole;
|
||||
this.userId = userId;
|
||||
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
|
||||
|
||||
+5
-1
@@ -31,7 +31,6 @@ public class Staff extends AbstractPersistable<Long> {
|
||||
@Column(name = "lastname", length = 50)
|
||||
private String lastname;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "display_name", length = 100)
|
||||
private String displayName;
|
||||
|
||||
@@ -47,6 +46,7 @@ public class Staff extends AbstractPersistable<Long> {
|
||||
@Column(name = "organisational_role_enum", nullable = true)
|
||||
private Integer organisationalRoleType;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "organisational_role_parent_staff_id", nullable = true)
|
||||
private Staff organisationalRoleParentStaff;
|
||||
@@ -158,4 +158,8 @@ public class Staff extends AbstractPersistable<Long> {
|
||||
public Long officeId() {
|
||||
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: "
|
||||
+ 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