/* * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import React from 'react'; import Utils from 'utils/utils.js'; import Button from 'widgets/button/rw.button.js'; import './login.scss' import rw from 'utils/rw.js'; class LoginScreen extends React.Component{ constructor(props) { super(props); var API_SERVER = rw.getSearchParams(window.location).api_server; if (!API_SERVER) { window.location.href = "//" + window.location.host + '/index.html?api_server=' + window.location.protocol + '//localhost'; } this.state = { username: '', password: '' }; } updateValue = (e) => { let state = {}; state[e.target.name] = e.target.value; this.setState(state); } validate = (e) => { let self = this; let state = this.state; e.preventDefault(); if (state.username == '' || state.password == '') { console.log('false'); return false; } else { Utils.setAuthentication(state.username, state.password, function() { //Returning to previous location disabled post port // let hash = window.sessionStorage.getItem("locationRefHash") || '#/'; // if (hash == '#/login') { // hash = '#/' // } // window.location.hash = hash; self.context.router.push('/'); }); } } submitForm = (e) => { if(e.keyCode == 13){ this.validate(e); } } render() { let html; html = (

Launchpad Login