<commit_before>import app from "app";
import {tryAction} from "ember-devise-simple-auth/utils";
import SessionRouteInitializer from "ember-devise-simple-auth/initializers/session-route";
import AuthenticatorInitializer from "ember-devise-simple-auth/initializers/authenticator";

Ember.Route.reopen({
  beforeModel: function() {
    if(this.skipsAuthentication) {
      return;
    }

    return this.get("authenticator").loadSession(this.get("store"));
  },
  _actions: {
    signOut: function() {
      this.get("authenticator").signOut();
      tryAction(this, "didSignOut");
    }
  }
});

Ember.Controller.reopen({
  isSignedIn: Ember.computed.alias("auth.isSignedIn"),
  currentSession: Ember.computed.alias("auth.currentSession")
});

app.initializer(SessionRouteInitializer);
app.initializer(AuthenticatorInitializer);<commit_msg>Block all transitions that require authentication<commit_after>import app from "app";
import {tryAction} from "ember-devise-simple-auth/utils";
import SessionRouteInitializer from "ember-devise-simple-auth/initializers/session-route";
import AuthenticatorInitializer from "ember-devise-simple-auth/initializers/authenticator";

Ember.Route.reopen({
  beforeModel: function() {
    if(this.skipsAuthentication) {
      return;
    }

    return this.get("authenticator").loadSession(this.get("store"));
  },
  _actions: {
    signOut: function() {
      this.get("authenticator").signOut();
      tryAction(this, "didSignOut");
    },
    willTransition: function(transition) {
      var routeKey    = "route:" + transition.targetName,
          targetRoute = this.container.lookup(routeKey),
          needsAuth = !(this.get("authenticator.isSignedIn")
                        || targetRoute.skipsAuthentication);

      if(needsAuth) {
        this.transitionTo("session");
      } else {
        return true;
      }
    }
  }
});

Ember.Controller.reopen({
  isSignedIn: Ember.computed.alias("auth.isSignedIn"),
  currentSession: Ember.computed.alias("auth.currentSession")
});

app.initializer(SessionRouteInitializer);
app.initializer(AuthenticatorInitializer);
{'fraction_non_alphanumeric': 0.1359315589353612, 'fraction_numerical': 0.0, 'mean_word_length': 4.2625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '571608', 'n_tokens_mistral': 641, 'n_tokens_neox': 629, 'n_words': 92}