<commit_before>/**
 * Created by groupsky on 10.11.15.
 */

require('../app').controller('SessionController', /* @ngInject */function ($log,
                                                            $rootScope,
                                                            $scope,
                                                            $state,
                                                            $stateParams,
                                                            $translate,
                                                            $uibModal,
                                                            api,
                                                            flashService,
                                                            user,
                                                            User) {
  var ctrl = this

  if ($stateParams.email) {
    $scope.auth = $scope.auth || {}
    $scope.user = $scope.user || {}
    $scope.auth.email = $scope.user.email = $stateParams.email
    if ($stateParams.token) { $scope.auth.token = $stateParams.token }
  }

  ctrl.login = function (auth) {
    ctrl.loading = true
    $scope.form.$setPristine()
    user.authenticate(auth).then(function (identity) {
      $log.debug('auth ok', identity)
      if ($rootScope.returnToState) {
        $state.go($rootScope.returnToState.name, $rootScope.returnToStateParams)
      } else {
        $state.go('auth.dashboard')
      }
    }, function (response) {
      $log.debug('auth err', response)
      flashService.error((response && (response.error || (response.data && response.data.error))) || $translate.instant('Invalid credentials'))
    }).finally(function () {
      ctrl.loading = false
    })
  }

  ctrl.register = function (user) {
    ctrl.loading = true
    $scope.form.$setPristine()
    User.save(user).$promise.then(function (response) {
      $log.debug('user created', response)
      flashService.success($translate.instant('Profile created successfully'), true)
      $state.go('login', {email: response.user.email})
    }, function (response) {
      $log.debug('error creating user', response)
      flashService.error(response.data.error || $translate.instant('Could not create profile'))
    }).finally(function () {
      ctrl.loading = false<commit_msg>Fix crash after register<commit_after>/**
 * Created by groupsky on 10.11.15.
 */

require('../app').controller('SessionController', /* @ngInject */function ($log,
                                                            $rootScope,
                                                            $scope,
                                                            $state,
                                                            $stateParams,
                                                            $translate,
                                                            $uibModal,
                                                            api,
                                                            flashService,
                                                            user,
                                                            User) {
  var ctrl = this

  if ($stateParams.email) {
    $scope.auth = $scope.auth || {}
    $scope.user = $scope.user || {}
    $scope.auth.email = $scope.user.email = $stateParams.email
    if ($stateParams.token) { $scope.auth.token = $stateParams.token }
  }

  ctrl.login = function (auth) {
    ctrl.loading = true
    $scope.form.$setPristine()
    user.authenticate(auth).then(function (identity) {
      $log.debug('auth ok', identity)
      if ($rootScope.returnToState) {
        $state.go($rootScope.returnToState.name, $rootScope.returnToStateParams)
      } else {
        $state.go('auth.dashboard')
      }
    }, function (response) {
      $log.debug('auth err', response)
      flashService.error((response && (response.error || (response.data && response.data.error))) || $translate.instant('Invalid credentials'))
    }).finally(function () {
      ctrl.loading = false
    })
  }

  ctrl.register = function (user) {
    ctrl.loading = true
    $scope.form.$setPristine()
    User.save(user).$promise.then(function (response) {
      $log.debug('user created', response)
      flashService.success($translate.instant('Profile created successfully'), true)
      $state.go('login', {email: user.email})
    }, function (response) {
      $log.debug('error creating user', response)
      flashService.error(response.data.error || $translate.instant('Could not create profile'))
    }).finally(function () {
      ctrl.loading = false
{'fraction_non_alphanumeric': 0.12364660025985275, 'fraction_numerical': 0.00259852750108272, 'mean_word_length': 1.3411049163710087, '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': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3010034', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1047, 'n_words': 200}