// Copyright (c) 2015-2016 Yuya Ochiai // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import PropTypes from 'prop-types'; import {Button, Col, ControlLabel, Form, FormGroup, FormControl, Modal} from 'react-bootstrap'; export default class LoginModal extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); this.usernameRef = React.createRef(); this.passwordRef = React.createRef(); } handleSubmit(event) { event.preventDefault(); const usernameNode = this.usernameRef.current; const passwordNode = this.passwordRef.current; this.props.onLogin(this.props.request, usernameNode.value, passwordNode.value); usernameNode.value = ''; passwordNode.value = ''; } render() { let theServer = ''; if (!this.props.show) { theServer = ''; } else if (this.props.authInfo.isProxy) { theServer = `The proxy ${this.props.authInfo.host}:${this.props.authInfo.port}`; } else { theServer = `The server ${this.props.authServerURL}`; } const message = `${theServer} requires a username and password.`; return ( {'Authentication Required'}

{ message }

{'User Name'} { e.stopPropagation(); }} /> {'Password'} { e.stopPropagation(); }} />
{ ' ' }
); } } LoginModal.propTypes = { authInfo: PropTypes.object, authServerURL: PropTypes.string, onCancel: PropTypes.func, onLogin: PropTypes.func, request: PropTypes.object, show: PropTypes.bool, };