<commit_before>
!( function( angular ) {
  if ( !angular ) throw new ReferenceError( 'angularjs 1.5+ is required' );
  angular.module( 'app' )
    .controller( 'sessionController', sessionController );

  function sessionController( $log, $scope, $location, $resource ) {
    const 
      vm = this,
      URL = 'http://localhost:3000';

    // ===# View models #=== //
    vm.authenticate = authenticate;

    function authenticate( auth ) {
      if ( $scope.formLogin.$invalid ) return;
      const
        AuthResource = $resource( '/auth/signin' ),
        authResource = new AuthResource( auth );

      authResource.$save()
        .then( user => {
          Promise.resolve( user )
            .then( serializeResponse )
            .then( createSession )
            .then( redirectToHome );
        })
        .catch( $log.error );
    }

    function createSession( user ) {
      sessionStorage.setItem( 'user', user );
      return user;
    }

    function serializeResponse( { _id, firstName, lastName, group, email } ) {
      return JSON.stringify( { _id, firstName, lastName, group, email } );
    }

    function redirectToHome() {
      $location.url( URL );
    }<commit_msg>[UPDATE]: Adicionado redirect para o path /.<commit_after>
!( function( angular ) {
  if ( !angular ) throw new ReferenceError( 'angularjs 1.5+ is required' );
  angular.module( 'app' )
    .controller( 'sessionController', sessionController );

  function sessionController( $log, $scope, $resource ) {
    const vm = this;

    // ===# View models #=== //
    vm.authenticate = authenticate;

    function authenticate( auth ) {
      if ( $scope.formLogin.$invalid ) return;
      const
        AuthResource = $resource( '/auth/signin' ),
        authResource = new AuthResource( auth );

      authResource.$save()
        .then( user => {
          Promise.resolve( user )
            .then( serializeResponse )
            .then( createSession )
            .then( redirectToHome )
            .catch( $log.error );
        })
        .catch( $log.error );
    }

    function createSession( user ) {
      sessionStorage.setItem( 'user', user );
      return user;
    }

    function serializeResponse( { _id, firstName, lastName, group, email } ) {
      return JSON.stringify( { _id, firstName, lastName, group, email } );
    }

    function redirectToHome() {
      location.pathname = '/';
    }
{'fraction_non_alphanumeric': 0.13352745424292845, 'fraction_numerical': 0.0033277870216306157, 'mean_word_length': 2.3035714285714284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2961244', 'n_tokens_mistral': 699, 'n_tokens_neox': 670, 'n_words': 174}