import Api from './api.js'; import App from './app.js'; import classNames from 'classnames'; import React from 'react'; class OtpQrCode extends React.Component { render = () => { return (

{this.props.secret}

); } } class OtpEnrollForm extends React.Component { constructor(props) { super(props); this.state = {'hideMsg': true, 'msg': '', 'msgOk': false, 'pass': ''}; } handleSubmit = (e) => { Api.Call('OTP_VALIDATE', {'pass': this.state.pass}, function(err, status, data) { if (err) { console.error(err, data); this.displayMessage(App.errorCodeToMessage(err.code), false); return; } this.displayMessage('OK', true); this.props.onSuccess(data.token); }.bind(this)); e.preventDefault(); } handlePassChange = (event) => { this.setState({'pass': event.target.value}); } hideMessage = () => { this.setState({'hideMsg': true}); } displayMessage = (msg, ok) => { this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); } render = () => { var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); var qrCode = null; if (this.props.img) { qrCode =

Please setup 2FA (Google Authenticator, Authy)

; } return (
{qrCode}
{this.state.msg}
); } } export default OtpEnrollForm;