Add profile scope, expose start and stop methods events service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
44cac3e1ab
commit
f4d1a04303
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { IEventMessage } from '../models/event.message';
|
import { IEventMessage } from '../models/event.message';
|
||||||
import { Subject, timer } from 'rxjs';
|
import { Subject, timer } from 'rxjs';
|
||||||
import { OAuthService } from 'angular-oauth2-oidc';
|
import { OAuthService } from 'angular-oauth2-oidc';
|
||||||
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from '@microsoft/signalr';
|
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType,HubConnectionState} from '@microsoft/signalr';
|
||||||
import { AppConfig } from "../shared/app.config";
|
import { AppConfig } from "../shared/app.config";
|
||||||
|
|
||||||
|
|
||||||
@ -31,12 +31,17 @@ export class EventService {
|
|||||||
this._connection.onreconnected( event => {
|
this._connection.onreconnected( event => {
|
||||||
this.Authenticate();
|
this.Authenticate();
|
||||||
});
|
});
|
||||||
|
this.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
Start() {
|
||||||
|
if(this._connection&&!(this._connection.state === HubConnectionState.Connected || this._connection.state === HubConnectionState.Connecting))
|
||||||
this._connection.start().then(() => {
|
this._connection.start().then(() => {
|
||||||
this.Authenticate();
|
this.Authenticate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Authenticate() {
|
private Authenticate() {
|
||||||
var accessToken = this.oauthService.getAccessToken();
|
var accessToken = this.oauthService.getAccessToken();
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
||||||
@ -48,4 +53,10 @@ export class EventService {
|
|||||||
}, 800);
|
}, 800);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stop() {
|
||||||
|
if(this._connection&&(this._connection.state === HubConnectionState.Connected || this._connection.state === HubConnectionState.Connecting)) {
|
||||||
|
this._connection.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export class Id4AuthconfigFactory implements IAuthconfigFactory {
|
|||||||
authConfig.redirectUri = window.location.origin + "/cb";
|
authConfig.redirectUri = window.location.origin + "/cb";
|
||||||
authConfig.clientId = appConfig.getConfig("clientId");
|
authConfig.clientId = appConfig.getConfig("clientId");
|
||||||
authConfig.customQueryParams = { audience: appConfig.getConfig("audience") };
|
authConfig.customQueryParams = { audience: appConfig.getConfig("audience") };
|
||||||
authConfig.scope = "api offline_access";
|
authConfig.scope = "profile api offline_access";
|
||||||
authConfig.disableAtHashCheck = true;
|
authConfig.disableAtHashCheck = true;
|
||||||
authConfig.responseType = "code";
|
authConfig.responseType = "code";
|
||||||
authConfig.requireHttps = appConfig.getConfig("requireHttps");
|
authConfig.requireHttps = appConfig.getConfig("requireHttps");
|
||||||
|
Loading…
Reference in New Issue
Block a user