{"size": 990, "ext": "js", "max_stars_repo_path": "src/views/tc-auth.js", "max_stars_repo_name": "twlv/twlv-chat-web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/views/tc-auth.js", "max_issues_repo_name": "twlv/twlv-chat-web", "max_issues_repo_issues_event_min_datetime": "2018-08-14T15:30:52.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-27T16:55:53.000Z", "max_forks_repo_path": "src/views/tc-auth.js", "max_forks_repo_name": "twlv/twlv-chat-web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 8, "max_forks_count": null, "avg_line_length": 17.6785714286, "max_line_length": 50, "alphanum_fraction": 0.5525252525}
import { define } from '@xinix/xin';
import { View } from '@xinix/xin/components/view';
import { Identity } from '@twlv/core';

import './tc-auth.scss';

class TcAuth extends View {
  get template () {
    return require('./tc-auth.html');
  }

  get props () {
    return Object.assign({}, super.props, {
      identity: {
        type: Object,
        value: () => (null),
      },
      computeAuth: {
        type: String,
        value: true,
      },
    });
  }

  signIn (evt) {
    evt.preventDefault();

    if (!this.identity) {
      throw new Error('Identity key is required');
    }

    this.__app.signIn(this.identity);

    this.__app.navigate('/');
  }

  computeOnline () {
    if (this.identity.privKey) {
      this.set('computeAuth', false);
      return;
    }
    this.set('computeAuth', true);
  }

  generate (evt) {
    evt.preventDefault();

    this.set({
      identity: Identity.generate(),
      computeAuth: false,
    });
  }
}

define('tc-auth', TcAuth);
