SUPPORT-9380: parse app number from socket response
This commit is contained in:
parent
29b63b5016
commit
e92f340af5
5 changed files with 7 additions and 33 deletions
|
|
@ -30,7 +30,7 @@ public class UserApplicationController {
|
||||||
|
|
||||||
@PutMapping(value = "/status", consumes = MediaType.APPLICATION_JSON_VALUE)
|
@PutMapping(value = "/status", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public Long updateStatus(@RequestBody ProcessResponseDto data) {
|
public Long updateStatus(@RequestBody ProcessResponseDto data) {
|
||||||
Long appNumber = Long.parseLong(data.appNumber());
|
Long appNumber = data.body().applicationNumber();
|
||||||
|
|
||||||
switch (data.className()) {
|
switch (data.className()) {
|
||||||
case UPDATE -> {
|
case UPDATE -> {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
* @author gulnaz
|
* @author gulnaz
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public record ProcessResponseBody(String type, String userName, @JsonProperty("value") String tempPass,
|
public record ProcessResponseBody(String type, Long applicationNumber, String userName,
|
||||||
|
@JsonProperty("value") String tempPass,
|
||||||
String secretLink, ProcessErrorMsg msg) {
|
String secretLink, ProcessErrorMsg msg) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,5 @@ import ru.micord.ervu.account_applications.websocket.enums.ClassName;
|
||||||
* @author gulnaz
|
* @author gulnaz
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public record ProcessResponseDto(String appNumber, String forUser, ClassName className,
|
public record ProcessResponseDto(String forUser, ClassName className, ProcessResponseBody body) {
|
||||||
ProcessResponseBody body) {
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ import {UnblockingData} from "./dto/blocking/UnblockingData";
|
||||||
export class UserManagementService extends Behavior {
|
export class UserManagementService extends Behavior {
|
||||||
|
|
||||||
private static PROCESS_START_PATH = '/service/wf/service/start';
|
private static PROCESS_START_PATH = '/service/wf/service/start';
|
||||||
private static ACCOUNT_BLOCK_PATH = "/service/idm/accounts/blocked/v1";
|
|
||||||
private static PERSON_BLOCK_PATH = "/service/idm/persons/blocked/v1";
|
|
||||||
|
|
||||||
@NotNull()
|
@NotNull()
|
||||||
@ObjectRef()
|
@ObjectRef()
|
||||||
|
|
@ -205,13 +203,7 @@ export class UserManagementService extends Behavior {
|
||||||
.then((response: ProcessResponse) => {
|
.then((response: ProcessResponse) => {
|
||||||
let code = response.code;
|
let code = response.code;
|
||||||
|
|
||||||
if (code === '200') {
|
if (code !== '200') {
|
||||||
localStorage.setItem(response.traceId, appNumber.toString());
|
|
||||||
setTimeout(() => {
|
|
||||||
localStorage.removeItem(response.traceId);
|
|
||||||
}, 30 * 60 * 1000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.saveError(appNumber, response.msg);
|
this.saveError(appNumber, response.msg);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@ export interface UserSession {
|
||||||
@Injectable({providedIn: 'root'})
|
@Injectable({providedIn: 'root'})
|
||||||
export class AuthorizationService implements OnDestroy {
|
export class AuthorizationService implements OnDestroy {
|
||||||
|
|
||||||
private static READ_LS_ATTEMPTS: number = 50;
|
|
||||||
|
|
||||||
private session: UserSession;
|
private session: UserSession;
|
||||||
|
|
||||||
public onSessionUpdate: Subject<UserSession> = new Subject<UserSession>();
|
public onSessionUpdate: Subject<UserSession> = new Subject<UserSession>();
|
||||||
|
|
@ -37,9 +35,9 @@ export class AuthorizationService implements OnDestroy {
|
||||||
this.websocketService.subscribe(({data}) => {
|
this.websocketService.subscribe(({data}) => {
|
||||||
let parsedObj = JSON.parse(data);
|
let parsedObj = JSON.parse(data);
|
||||||
|
|
||||||
if (parsedObj && parsedObj.traceId) {
|
if (parsedObj && parsedObj.body && parsedObj.body.applicationNumber) {
|
||||||
if (parsedObj.className === 'update' || parsedObj.className === 'processError') {
|
if (parsedObj.className === 'update' || parsedObj.className === 'processError') {
|
||||||
this.updateStatus(parsedObj, 0);
|
this.statusUpdateService.update(parsedObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -48,22 +46,6 @@ export class AuthorizationService implements OnDestroy {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateStatus(parsedObj: any, count: number): void {
|
|
||||||
if (count === AuthorizationService.READ_LS_ATTEMPTS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let appNumber = localStorage.getItem(parsedObj.traceId);
|
|
||||||
|
|
||||||
if (appNumber) {
|
|
||||||
parsedObj.appNumber = appNumber;
|
|
||||||
localStorage.removeItem(parsedObj.traceId);
|
|
||||||
this.statusUpdateService.update(parsedObj);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setTimeout(() => this.updateStatus(parsedObj, count++), 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isAuthorized(): boolean {
|
isAuthorized(): boolean {
|
||||||
return !!this.session;
|
return !!this.session;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue