X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=cmd%2Fweb%2Fjs%2Fotp.jsx;h=5f04e21da2968fdffefebb24dd9191cbef28d745;hb=a6820180928670b0642fa6a28ac221ce158230bb;hp=2717d9f30ccef24e7166764d175334c09c6e5a8b;hpb=7a9e5112eaaea58d55f181d3e5296e4ff839921c;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FFront.git diff --git a/cmd/web/js/otp.jsx b/cmd/web/js/otp.jsx index 2717d9f..5f04e21 100644 --- a/cmd/web/js/otp.jsx +++ b/cmd/web/js/otp.jsx @@ -1,9 +1,10 @@ -var Api = require('./api.js').Api; -var App = require('./app.js'); -var classNames = require('classnames'); +import Api from './api.js'; +import App from './app.js'; +import classNames from 'classnames'; +import React from 'react'; -var OtpQrCode = React.createClass({ - render: function() { +class OtpQrCode extends React.Component { + render = () => { return (
@@ -11,13 +12,15 @@ var OtpQrCode = React.createClass({
); } -}); +} -module.exports.OtpEnrollForm = React.createClass({ - getInitialState: function() { - return {'hideMsg': true, 'msg': '', 'msgOk': false, 'pass': ''}; - }, - handleSubmit: function(e) { +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); @@ -31,40 +34,47 @@ module.exports.OtpEnrollForm = React.createClass({ }.bind(this)); e.preventDefault(); - }, - handlePassChange: function(event) { + } + + handlePassChange = (event) => { this.setState({'pass': event.target.value}); - }, - hideMessage: function() { + } + + hideMessage = () => { this.setState({'hideMsg': true}); - }, - displayMessage: function(msg, ok) { + } + + displayMessage = (msg, ok) => { this.setState({'msg': msg, 'msgOk': ok, 'hideMsg': false}); - }, - render: function() { + } + + render = () => { var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk}); var qrCode = null; if (this.props.img) { - qrCode = ( -
+ qrCode = +
+

Please setup 2FA (Google Authenticator, Authy)

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