<commit_before>'use strict';

module.exports = function(app) {
  app.service('AuthService', ['$rootScope', '$http', '$location', function($rs, $http, $location) {

    this.signup = function(userData) {
      $http.post(`${$rs.baseUrl}/users/signup`, userData)
        .then((res) => {
          delete res.config.data.password;
          $rs.user = res.data;
          window.sessionStorage.setItem('currentUser', JSON.stringify($rs.user));
          $location.path('/dashboard');
        })
        .catch((err) => {
          alert('Error creating user.');
        });
    };

    this.signin = function(userData) {
      $http.post(`${$rs.baseUrl}/users/signin`, userData)
        .then((res) => {
          delete res.config.data.password;
          $rs.user = res.data;
          window.sessionStorage.setItem('currentUser', JSON.stringify($rs.user));
          $location.path('/dashboard');
        })
        .catch((err) => {
          alert('Error signing in.');
        });
    };

    this.signout = function() {
      $http.get(`${$rs.baseUrl}/users/signout`)
        .then((res) => {
          window.sessionStorage.removeItem('currentUser');
          $location.path('/signin');
        })
        .catch((err) => {
          alert('Error signing out.');
        });
    };

    this.checkSessionExists = function() {
      let currentUser = window.sessionStorage.getItem('currentUser');
      currentUser === null ? $location.path('/') : true;
    };

  }]);
};
<commit_msg>checkSessionExists method will assign root scope user object to session storage currentUser if not null<commit_after>'use strict';

module.exports = function(app) {
  app.service('AuthService', ['$rootScope', '$http', '$location', function($rs, $http, $location) {

    this.signup = function(userData) {
      $http.post(`${$rs.baseUrl}/users/signup`, userData)
        .then((res) => {
          delete res.config.data.password;
          $rs.user = res.data;
          window.sessionStorage.setItem('currentUser', JSON.stringify($rs.user));
          $location.path('/dashboard');
        })
        .catch((err) => {
          alert('Error creating user.');
        });
    };

    this.signin = function(userData) {
      $http.post(`${$rs.baseUrl}/users/signin`, userData)
        .then((res) => {
          delete res.config.data.password;
          $rs.user = res.data;
          window.sessionStorage.setItem('currentUser', JSON.stringify($rs.user));
          $location.path('/dashboard');
        })
        .catch((err) => {
          alert('Error signing in.');
        });
    };

    this.signout = function() {
      $http.get(`${$rs.baseUrl}/users/signout`)
        .then((res) => {
          window.sessionStorage.removeItem('currentUser');
          $location.path('/signin');
        })
        .catch((err) => {
          alert('Error signing out.');
        });
    };

    this.checkSessionExists = function() {
      let currentUser = window.sessionStorage.getItem('currentUser');
      currentUser === null ? $location.path('/') : $rs.user = JSON.parse(currentUser);
    };

  }]);
};

{'fraction_non_alphanumeric': 0.18451612903225806, 'fraction_numerical': 0.0, 'mean_word_length': 2.3165775401069517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7540247', 'n_tokens_mistral': 912, 'n_tokens_neox': 913, 'n_words': 139}