<commit_before>import {inject} from 'aurelia-framework';
import {AuthService} from 'aurelia-auth';
import {NewsService} from '../../services/news/news-service';

@inject(NewsService, AuthService)
export class View {
  constructor(newsService, authService) {
    this.newsService = newsService;
    this.authService = authService;
  }

  activate(params, routeConfig) {
    let user = this.authService.getMe()
      .then(user => {
        this.user = user;
      });

    let news = this.newsService.get(params.id)
      .then(news => {
        this.news = news;
        routeConfig.navModel.setTitle(news.title);
      })
      .catch(() => {
        this.news = null;
      });

    return Promise.all([user, news]);
  }

  get isAuthenticated() {
    return this.authService.isAuthenticated();
  }
}
<commit_msg>fix(news): fix news view if user is not logged in<commit_after>import {inject} from 'aurelia-framework';
import {AuthService} from 'aurelia-auth';
import {NewsService} from '../../services/news/news-service';

@inject(NewsService, AuthService)
export class View {
  constructor(newsService, authService) {
    this.newsService = newsService;
    this.authService = authService;
  }

  activate(params, routeConfig) {
    let user = this.authService.getMe()
      .then(user => {
        this.user = user;
      })
      .catch(() => {
        this.user = null;
      });

    let news = this.newsService.get(params.id)
      .then(news => {
        this.news = news;
        routeConfig.navModel.setTitle(news.title);
      })
      .catch(() => {
        this.news = null;
      });

    return Promise.all([user, news]);
  }

  get isAuthenticated() {
    return this.authService.isAuthenticated();
  }
}

{'fraction_non_alphanumeric': 0.14576074332171893, 'fraction_numerical': 0.0, 'mean_word_length': 2.7375271149674623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7364165', 'n_tokens_mistral': 543, 'n_tokens_neox': 536, 'n_words': 108}