Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- principal.isAuthenticated()
- principal.hasAnyAuthority(['ROLE_ADMIN'])
- ngAfterContentChecked() {
- console.log('ngAfterContentChecked');
- console.log(this.principal.isAuthenticated());
- }
- <div>{{isAuthenticated()}}</div>
- if(!this.isAuthenticated()) {
- this.model.push({ label: 'Sign in', icon: 'fa fa-fw fa-sign-in', command: (onclick)=> {this.login()} });
- } else {
- this.model.push({ label: 'Sign out', icon: 'fa fa-fw fa-sign-in', command: (onclick)=> {this.logout()} });
- }
- this.principal.identity().then((account) => {
- this.currentAccount = account;
- });
- core.js?593e:1440 ERROR TypeError: _this.connectedPromise is not a function
- at eval (tracker.service.ts?aa77:50)
- at eval (webstomp.js?afe9:292)
- at Array.forEach (<anonymous>)
- at SockJS.ws.onmessage (webstomp.js?afe9:284)
- at SockJS.EventTarget.dispatchEvent (eventtarget.js?d62b:51)
- at eval (main.js?8e93:274)
- at Array.forEach (<anonymous>)
- at SockJS._transportMessage (main.js?8e93:272)
- at WebSocketTransport.EventEmitter.emit (emitter.js?a8c1:50)
- at WebSocketTransport.ws.onmessage [as __zone_symbol__ON_PROPERTYmessage] (websocket.js?a354:35)
- defaultErrorLogger @ core.js?593e:1440
- ErrorHandler.handleError @ core.js?593e:1501
- next @ core.js?593e:5481
- schedulerFn @ core.js?593e:4319
- SafeSubscriber.__tryOrUnsub @ Subscriber.js?3959:240
- SafeSubscriber.next @ Subscriber.js?3959:187
- Subscriber._next @ Subscriber.js?3959:128
- Subscriber.next @ Subscriber.js?3959:92
- Subject.next @ Subject.js?8398:56
- EventEmitter.emit @ core.js?593e:4299
- (anonymous) @ core.js?593e:4755
- ZoneDelegate.invoke @ zone.js?6524:388
- Zone.run @ zone.js?6524:138
- NgZone.runOutsideAngular @ core.js?593e:4681
- onHandleError @ core.js?593e:4755
- ZoneDelegate.handleError @ zone.js?6524:392
- Zone.runTask @ zone.js?6524:191
- ZoneTask.invokeTask @ zone.js?6524:495
- invokeTask @ zone.js?6524:1536
- globalZoneAwareCallback @ zone.js?6524:1562
- ngOnInit() {
- setTimeout(() => {
- this.loadMenu();
- }, 0);
- }
- ngOnInit() {
- /**
- * This will load the menu, but only show items that do not require login
- * because the principal is not valued yet.
- */
- this.loadMenu();
- /**
- * This interval will run until the user is authenticated and then will reload the menu and clear the interval.
- */
- this.intervalId = setInterval(() => {
- if(this.isAuthenticated()) {
- this.loadMenu();
- clearInterval(this.intervalId);
- }
- }, 100);
- }
- ngOnInit() {
- this.registerAuthenticationSuccess();
- }
- registerAuthenticationSuccess() {
- this.eventManager.subscribe('authenticationSuccess', (message) => {
- this.getAccount();
- });
- }
- getAccount() {
- this.principal.identity().then((account) => {
- this.account = account;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement