<commit_before>var auth2;

function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();
  var Storage = window.localStorage;

  $.getJSON('/login', {
    email: profile.getEmail()
  }, function(data) {
    console.log('before: ' + data);
    // on success, check if user exists. yes: check if confirmed, then redirect; no: make new user
    if (data) {
      if (data.permissions.stage === -1) {
        // gapi.auth2.getAuthInstance().signOut();          // temporarily commented until confirmation is available
        $('#alertDeactivated').hide();
        $('#alertRegistered').hide();
        $('#alertProblem').hide();
        $('#alertUnconfirmed').show('fast');

        window.location.href = "overview";                  // temporary for access even without confirmation

      } else if (data.permissions.stage === -2) {
        gapi.auth2.getAuthInstance().signOut();
        $('#alertUnconfirmed').hide();
        $('#alertRegistered').hide();
        $('#alertProblem').hide();
        $('#alertDeactivated').show('fast');
      } else {
        data.imageUrl = profile.getImageUrl();

        // update user image data in db

        console.log('after: ' + data);
        window.location.href = "overview";
      }
    } else {
      var newUser = {
        "name" : profile.getName(),
        "email" : profile.getEmail(),
        "imageUrl" : profile.getImageUrl(),
        "title" : "",
        "permissions" : {
          "level" : -1,
          "stage" : -1
        },
        "grantIds" : []
      };

      $.ajax({
        url: 'users',
        type: 'PUT',
        contentType: 'application/json',
        data: JSON.stringify(newUser),
        success: function(data) {
          gapi.auth2.getAuthInstance().signOut();
          $('#alertDeactivated').hide();<commit_msg>user login will store and updated profile image url.<commit_after>var auth2;

function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();
  var Storage = window.localStorage;

  $.getJSON('/login', {
    email: profile.getEmail()
  }, function(data) {
    console.log('before: ' + data);
    // on success, check if user exists. yes: check if confirmed, then redirect; no: make new user
    if (data) {
      if (data.permissions.stage === -1) {
        // gapi.auth2.getAuthInstance().signOut();          // temporarily commented until confirmation is available
        $('#alertDeactivated').hide();
        $('#alertRegistered').hide();
        $('#alertProblem').hide();
        $('#alertUnconfirmed').show('fast');

        window.location.href = "overview";                  // temporary for access even without confirmation

      } else if (data.permissions.stage === -2) {
        gapi.auth2.getAuthInstance().signOut();
        $('#alertUnconfirmed').hide();
        $('#alertRegistered').hide();
        $('#alertProblem').hide();
        $('#alertDeactivated').show('fast');
      } else {  // update user image data in db, then go to overview
        $.ajax({
          url: '/users/' + data._id,
          type: 'POST',
          contentType: "application/json",
          data: JSON.stringify({
            $set: { 'imageUrl': profile.getImageUrl() }
          }),
          success: function () {
            window.location.href = "overview";
          },
          error: function () {
            alert('There was a problem processing your request. Please try again later.');
          }
        });
      }
    } else {
      var newUser = {
        "name" : profile.getName(),
        "email" : profile.getEmail(),
        "imageUrl" : profile.getImageUrl(),
        "title" : "",
        "permissions" : {
          "level" : -1,
          "stage" : -1
        },
        "grantIds" : []
      };

      $.ajax({
        url: 'users',
        type: 'PUT',
        contentType: 'application/json',
        data: JSON.stringify(newUser),
        success: function(data) {
          gapi.auth2.getAuthInstance().signOut();
          $('#alertDeactivated').hide();
{'fraction_non_alphanumeric': 0.16313823163138233, 'fraction_numerical': 0.00398505603985056, 'mean_word_length': 2.1059551430781127, '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': '1767552', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1102, 'n_words': 249}