<commit_before>part of couclient;

String SLACK_TEAM;
String SLACK_TOKEN;
String SC_TOKEN;

String SESSION_TOKEN;

class AuthManager {
  String _authUrl = 'https://server.childrenofur.com:8383/auth';

  Persona _personaNavigator;
  Element _loginButton;

  AuthManager() {
    // Starts the game
    _loginButton = querySelector('#login-button');
    _personaNavigator = new Persona('', verifyWithServer, view.loggedOut);
    _loginButton.onClick.listen((_) {
      _personaNavigator.request({
        'backgroundColor': '#4b2e4c',
        'siteName': 'Children of Ur'
      });
      _loginButton.hidden = true;
    });
  }

  
  void verifyWithServer(String personaAssertion) {
    _loginButton.hidden = true;

    Timer tooLongTimer = new Timer(new Duration(seconds: 5),(){
      SpanElement greeting = querySelector('#greeting');
      greeting.text = '''
Oh no!
Looks like the server is a bit slow. 
Please check back another time. :(''';
    });

    HttpRequest.request(_authUrl + "/login", method: "POST", requestHeaders: {
      "content-type": "application/json"
    }, sendData: JSON.encode({
      'assertion': personaAssertion,
      'audience' : 'http://localhost:8080/index.html'
      //'audience':'http://robertmcdermot.com/cou:80'
    }))
      ..then((HttpRequest data) {
      tooLongTimer.cancel();
      Map serverdata = JSON.decode(data.response);
      
      SESSION_TOKEN = serverdata['sessionToken'];
      SLACK_TEAM = serverdata['slack-team'];
      SLACK_TOKEN = serverdata['slack-token'];
      SC_TOKEN = serverdata['sc-token'];
      
      if (serverdata['playerName'].trim() == '') {
        setupNewUser();
        window.location.href = 'http://childrenofur.com/forums/login';
      }
      else startGame(serverdata);
    });
  }

  void logout() {
      _personaNavigator.logout();
      window.location.reload();
  }
  
  
  startGame(Map serverdata) {
    if (serverdata['ok'] == 'no') {
      print('Error:Server refused the login attempt.');
      _loginButton.hidden = false;<commit_msg>added some session vars back in (oops)<commit_after>part of couclient;

String SLACK_TEAM;
String SLACK_TOKEN;
String SC_TOKEN;

String SESSION_TOKEN;

class AuthManager {
  String _authUrl = 'https://server.childrenofur.com:8383/auth';

  Persona _personaNavigator;
  Element _loginButton;

  AuthManager() {
    // Starts the game
    _loginButton = querySelector('#login-button');
    _personaNavigator = new Persona('', verifyWithServer, view.loggedOut);
    _loginButton.onClick.listen((_) {
      _personaNavigator.request({
        'backgroundColor': '#4b2e4c',
        'siteName': 'Children of Ur'
      });
      _loginButton.hidden = true;
    });
  }

  
  void verifyWithServer(String personaAssertion) {
    _loginButton.hidden = true;

    Timer tooLongTimer = new Timer(new Duration(seconds: 5),(){
      SpanElement greeting = querySelector('#greeting');
      greeting.text = '''
Oh no!
Looks like the server is a bit slow. 
Please check back another time. :(''';
    });

    HttpRequest.request(_authUrl + "/login", method: "POST", requestHeaders: {
      "content-type": "application/json"
    }, sendData: JSON.encode({
      'assertion': personaAssertion,
      'audience' : 'http://localhost:8080/index.html'
      //'audience':'http://robertmcdermot.com/cou:80'
    }))
      ..then((HttpRequest data) {
      tooLongTimer.cancel();
      Map serverdata = JSON.decode(data.response);
      
      if (serverdata['ok'] == 'no') {
        print('Error:Server refused the login attempt.');
        _loginButton.hidden = false;
        return;
      }
      
      SESSION_TOKEN = serverdata['sessionToken'];
      SLACK_TEAM = serverdata['slack-team'];
      SLACK_TOKEN = serverdata['slack-token'];
      SC_TOKEN = serverdata['sc-token'];
      
      if (serverdata['playerName'].trim() == '') {
        setupNewUser();
        window.location.href = 'http://childrenofur.com/forums/login';
      }
      else {
        // Get our username and location from the server.
        sessionStorage['playerName'] = serverdata['playerName'];
        sessionStorage['playerStreet'] = serverdata['playerStreet'];
        startGame(serverdata);
      }
    });
  }

  void logout() {
      _personaNavigator.logout();
      window.location.reload();
  }
  
  
  startGame(Map serverdata) {
    if (serverdata['ok'] == 'no') {
      print('Error:Server refused the login attempt.');
      _loginButton.hidden = false;
{'fraction_non_alphanumeric': 0.14032728087872676, 'fraction_numerical': 0.006276619592019726, 'mean_word_length': 3.023444544634806, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '631046', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1367, 'n_words': 272}