mirror of
https://github.com/gosticks/web.git
synced 2026-12-04 10:11:38 +00:00
Generated
+10
-12
@@ -2957,7 +2957,7 @@
|
||||
"inherits": "2.0.3",
|
||||
"md5.js": "1.3.4",
|
||||
"ripemd160": "2.0.2",
|
||||
"sha.js": "2.4.8"
|
||||
"sha.js": "2.4.11"
|
||||
}
|
||||
},
|
||||
"create-hmac": {
|
||||
@@ -2971,7 +2971,7 @@
|
||||
"inherits": "2.0.3",
|
||||
"ripemd160": "2.0.2",
|
||||
"safe-buffer": "5.1.1",
|
||||
"sha.js": "2.4.8"
|
||||
"sha.js": "2.4.11"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
@@ -6783,8 +6783,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.4",
|
||||
@@ -9830,7 +9829,7 @@
|
||||
"create-hmac": "1.1.7",
|
||||
"ripemd160": "2.0.2",
|
||||
"safe-buffer": "5.1.1",
|
||||
"sha.js": "2.4.8"
|
||||
"sha.js": "2.4.11"
|
||||
}
|
||||
},
|
||||
"performance-now": {
|
||||
@@ -12296,8 +12295,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
|
||||
"dev": true
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||
},
|
||||
"safe-regex": {
|
||||
"version": "1.1.0",
|
||||
@@ -12609,12 +12607,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"sha.js": {
|
||||
"version": "2.4.8",
|
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.8.tgz",
|
||||
"integrity": "sha1-NwaMLEdra69ALRSknGf1l5IfY08=",
|
||||
"dev": true,
|
||||
"version": "2.4.11",
|
||||
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
|
||||
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
|
||||
"requires": {
|
||||
"inherits": "2.0.3"
|
||||
"inherits": "2.0.3",
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"shebang-command": {
|
||||
|
||||
+2
-1
@@ -22,7 +22,8 @@
|
||||
"react-router-dom": "^4.2.2",
|
||||
"react-table": "^6.8.2",
|
||||
"react-transition-group": "^2.3.1",
|
||||
"reactstrap": "^5.0.0"
|
||||
"reactstrap": "^5.0.0",
|
||||
"sha.js": "^2.4.11"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ignoreCancel, makeCancelable } from "../utils";
|
||||
import { api, ignoreCancel, makeCancelable } from "../utils";
|
||||
|
||||
export default class DomainInput extends Component {
|
||||
state = {
|
||||
@@ -49,11 +49,16 @@ export default class DomainInput extends Component {
|
||||
type="text" className="form-control" placeholder="Add a domain (example.com or sub.example.com)"
|
||||
value={this.state.domain} onKeyPress={(e) => e.charCode === 13 ? this.onAdd() : null}
|
||||
onChange={this.handleChange}
|
||||
disabled={!api.loggedIn}
|
||||
/>
|
||||
<span className="input-group-btn">
|
||||
<button onClick={this.onAdd} className="btn btn-secondary" type="button">
|
||||
Add
|
||||
</button>
|
||||
{
|
||||
api.loggedIn ?
|
||||
<button onClick={this.onAdd} className="btn btn-secondary" type="button">
|
||||
Add
|
||||
</button>
|
||||
: null
|
||||
}
|
||||
<button onClick={this.props.onRefresh} className="btn btn-secondary" type="button">
|
||||
<i className="fa fa-refresh"/>
|
||||
</button>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ignoreCancel, makeCancelable } from "../utils";
|
||||
import { api, ignoreCancel, makeCancelable } from "../utils";
|
||||
|
||||
export default class DomainList extends Component {
|
||||
onRemove(domain) {
|
||||
@@ -34,9 +34,13 @@ export default class DomainList extends Component {
|
||||
?
|
||||
this.props.domains.map(item => (
|
||||
<li key={item} className="list-group-item">
|
||||
<button className="btn btn-danger btn-sm pull-right" type="button" onClick={() => this.onRemove(item)}>
|
||||
<span className="fa fa-trash-o"/>
|
||||
</button>
|
||||
{
|
||||
api.loggedIn ?
|
||||
<button className="btn btn-danger btn-sm pull-right" type="button" onClick={() => this.onRemove(item)}>
|
||||
<span className="fa fa-trash-o"/>
|
||||
</button>
|
||||
: null
|
||||
}
|
||||
<span style={{ display: "table-cell", verticalAlign: "middle", height: "32px" }}>
|
||||
{item}
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* Web Interface
|
||||
* Forgot Password Reminder
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export default class ForgotPassword extends Component {
|
||||
state = {
|
||||
collapsed: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle collapsing the body when clicked
|
||||
*/
|
||||
onClick = () => {
|
||||
this.setState({ collapsed: !this.state.collapsed });
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Boolean|boolean} If the body should be expanded
|
||||
*/
|
||||
isExpanded = () => this.props.error || !this.state.collapsed;
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div style={{'width': '100%'}}>
|
||||
<div className={'card ' + (this.props.error ? 'border-danger': 'border-primary')}>
|
||||
<div className={'card-header ' + (this.props.error ? 'bg-danger' : 'bg-primary')}
|
||||
style={{'paddingRight': '10px', 'paddingBottom': "0px"}}>
|
||||
<h3 className="card-title" style={{'fontSize': '18px', 'display': 'inline-block', 'margin': 0}}>
|
||||
Forgot password
|
||||
</h3>
|
||||
|
||||
<span className="pull-right">
|
||||
<button type="button" className="btn btn-card-tool"
|
||||
style={{ 'cursor': 'pointer', 'padding': '10px' }} onClick={this.onClick}>
|
||||
<i className={'fa ' + (this.isExpanded() ? 'fa-minus' : 'fa-plus')}/>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<div className={'card-body bg-light' + (this.isExpanded() ? '' : ' collapse')}
|
||||
style={{'padding': '10px'}}>
|
||||
After installing Pi-hole for the first time, a password is generated and displayed to the user.
|
||||
The password cannot be retrieved later on, but it is possible to set a new password (or
|
||||
explicitly disable the password by setting an empty password) using the command:
|
||||
<pre style={{'textAlign': 'center'}}>sudo pihole -a -p</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ForgotPassword.propTypes = {
|
||||
error: PropTypes.bool.isRequired
|
||||
};
|
||||
@@ -13,44 +13,60 @@ import { NavLink } from 'react-router-dom'
|
||||
import { Nav, NavItem } from 'reactstrap';
|
||||
import logo from '../img/logo.svg';
|
||||
import { mobileSidebarHide } from "./Header";
|
||||
import { api } from "../utils";
|
||||
|
||||
const nav = {
|
||||
items: [
|
||||
{
|
||||
name: 'Dashboard',
|
||||
url: '/dashboard',
|
||||
icon: 'fa fa-dashboard'
|
||||
icon: 'fa fa-dashboard',
|
||||
auth: false
|
||||
},
|
||||
{
|
||||
name: 'Query Log',
|
||||
url: '/query-log',
|
||||
icon: 'fa fa-database'
|
||||
icon: 'fa fa-database',
|
||||
auth: true
|
||||
},
|
||||
{
|
||||
name: 'Whitelist',
|
||||
url: '/whitelist',
|
||||
icon: 'fa fa-check-circle-o'
|
||||
icon: 'fa fa-check-circle-o',
|
||||
auth: false
|
||||
},
|
||||
{
|
||||
name: 'Blacklist',
|
||||
icon: 'fa fa-ban',
|
||||
auth: false,
|
||||
children: [
|
||||
{
|
||||
name: 'Exact',
|
||||
url: '/blacklist',
|
||||
icon: 'fa fa-ban'
|
||||
icon: 'fa fa-ban',
|
||||
auth: false
|
||||
},
|
||||
{
|
||||
name: 'Wildcard',
|
||||
url: '/wildlist',
|
||||
icon: 'fa fa-ban'
|
||||
icon: 'fa fa-ban',
|
||||
auth: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Login',
|
||||
url: '/login',
|
||||
icon: 'fa fa-user'
|
||||
icon: 'fa fa-user',
|
||||
auth: false,
|
||||
authStrict: true
|
||||
},
|
||||
{
|
||||
name: 'Logout',
|
||||
url: '/logout',
|
||||
icon: 'fa fa-user-times',
|
||||
auth: true,
|
||||
authStrict: true
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -81,7 +97,18 @@ const navDropdown = (item, key, props) => (
|
||||
);
|
||||
|
||||
const navList = (items, props) =>
|
||||
items.map((item, index) => item.children ? navDropdown(item, index, props) : navItem(item, index));
|
||||
items.map((item, index) => {
|
||||
// Don't show an item if it requires auth and we're not logged in
|
||||
if(item.auth && !api.loggedIn)
|
||||
return null;
|
||||
|
||||
// Some items (login page) should only be shown when logged in or logged out, not both
|
||||
if(item.authStrict && item.auth !== api.loggedIn)
|
||||
return null;
|
||||
|
||||
// At this point it's ok to show the item
|
||||
return item.children ? navDropdown(item, index, props) : navItem(item, index);
|
||||
});
|
||||
|
||||
export default props => {
|
||||
return (
|
||||
|
||||
+32
-1
@@ -21,6 +21,8 @@ import Whitelist from "../views/Whitelist";
|
||||
import Blacklist from "../views/Blacklist";
|
||||
import Wildlist from "../views/Wildlist";
|
||||
import Login from "../views/Login";
|
||||
import Logout from "../views/Logout";
|
||||
import { api } from "../utils";
|
||||
|
||||
export default props => (
|
||||
<div className="app">
|
||||
@@ -33,11 +35,12 @@ export default props => (
|
||||
<Switch>
|
||||
<Route path="/dashboard" name="Dashboard" component={Dashboard}/>
|
||||
<Redirect exact from="/" to="/dashboard"/>
|
||||
<Route path="/query-log" name="Query Log" component={QueryLog}/>
|
||||
<AuthRoute path="/query-log" name="Query Log" component={QueryLog}/>
|
||||
<Route path="/whitelist" name="Whitelist" component={Whitelist}/>
|
||||
<Route path="/blacklist" name="Blacklist" component={Blacklist}/>
|
||||
<Route path="/wildlist" name="Wildlist" component={Wildlist}/>
|
||||
<Route path="/login" name="Login" component={Login}/>
|
||||
<AuthRoute path="/logout" name="Logout" component={Logout}/>
|
||||
</Switch>
|
||||
</div>
|
||||
</main>
|
||||
@@ -46,3 +49,31 @@ export default props => (
|
||||
<Footer/>
|
||||
</div>
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a route which requires authentication.
|
||||
* If the user is unauthenticated, they will be redirected to the login page.
|
||||
* If the user logs in at the redirected login page, they will go to their original destination.
|
||||
*
|
||||
* @param Component The component that the authenticated user will see
|
||||
* @param rest The rest of the Route arguments
|
||||
* @returns Route
|
||||
*/
|
||||
const AuthRoute = ({ component: Component, ...rest }) => (
|
||||
<Route
|
||||
{...rest}
|
||||
render={props =>
|
||||
api.loggedIn ? (
|
||||
<Component {...props} />
|
||||
) : (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: "/login",
|
||||
state: { from: props.location }
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ import ReactDOM from 'react-dom';
|
||||
import { HashRouter, Route, Switch } from 'react-router-dom'
|
||||
import 'ionicons/dist/css/ionicons.min.css';
|
||||
import Full from './containers/Full'
|
||||
import { api } from "./utils";
|
||||
|
||||
// Before rendering anything, check if there is a session cookie.
|
||||
// Note: the user could have an old session, so the first API call
|
||||
// will set loggedIn to false if necessary
|
||||
api.loggedIn = document.cookie.includes("user_id=");
|
||||
|
||||
ReactDOM.render(
|
||||
(
|
||||
|
||||
+2
-1
@@ -14,5 +14,6 @@ export default {
|
||||
'/whitelist': 'Whitelist',
|
||||
'/blacklist': 'Blacklist (Exact)',
|
||||
'/wildlist': 'Blacklist (Wildcard)',
|
||||
'/login': 'Login'
|
||||
'/login': 'Login',
|
||||
'/logout': 'Logout'
|
||||
};
|
||||
|
||||
+44
-4
@@ -20,7 +20,7 @@ export const makeCancelable = (promise, { repeat = null, interval = 0 } = {}) =>
|
||||
|
||||
const handle = (resolve, reject, val, isError) => {
|
||||
if(hasCanceled)
|
||||
reject({isCanceled: true});
|
||||
reject({ isCanceled: true });
|
||||
else {
|
||||
if(isError)
|
||||
reject(val);
|
||||
@@ -54,6 +54,18 @@ export const ignoreCancel = err => {
|
||||
};
|
||||
|
||||
export const api = {
|
||||
loggedIn: false,
|
||||
authenticate(key) {
|
||||
return fetch(api.urlFor("auth"), {
|
||||
headers: new Headers({ "X-Pi-hole-Authenticate": key }),
|
||||
credentials: this.credentialType()
|
||||
})
|
||||
.then(api.convertJSON)
|
||||
.then(api.checkForErrors);
|
||||
},
|
||||
logout() {
|
||||
return api.delete("auth");
|
||||
},
|
||||
getSummary() {
|
||||
return api.get("stats/summary");
|
||||
},
|
||||
@@ -106,7 +118,10 @@ export const api = {
|
||||
return api.delete("dns/wildlist/" + domain);
|
||||
},
|
||||
get(url) {
|
||||
return fetch(api.urlFor(url))
|
||||
return fetch(api.urlFor(url), {
|
||||
credentials: this.credentialType()
|
||||
})
|
||||
.then(api.checkIfLoggedOut)
|
||||
.then(api.convertJSON)
|
||||
.then(api.checkForErrors);
|
||||
},
|
||||
@@ -114,16 +129,36 @@ export const api = {
|
||||
return fetch(api.urlFor(url), {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
headers: new Headers({ "Content-Type": "application/json" })
|
||||
headers: new Headers({ "Content-Type": "application/json" }),
|
||||
credentials: this.credentialType()
|
||||
})
|
||||
.then(api.checkIfLoggedOut)
|
||||
.then(api.convertJSON)
|
||||
.then(api.checkForErrors);
|
||||
},
|
||||
delete(url) {
|
||||
return fetch(api.urlFor(url), { method: "DELETE" })
|
||||
return fetch(api.urlFor(url), {
|
||||
method: "DELETE",
|
||||
credentials: this.credentialType()
|
||||
})
|
||||
.then(api.checkIfLoggedOut)
|
||||
.then(api.convertJSON)
|
||||
.then(api.checkForErrors);
|
||||
},
|
||||
/**
|
||||
* If the user is logged in, check if the user's session has lapsed.
|
||||
* If so, log them out and refresh the page.
|
||||
*/
|
||||
checkIfLoggedOut(response) {
|
||||
if(api.loggedIn && response.status === 401) {
|
||||
// Clear the user's old session and refresh the page
|
||||
document.cookie = 'user_id=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
window.location.reload();
|
||||
return Promise.reject({ isCanceled: true })
|
||||
}
|
||||
|
||||
return Promise.resolve(response);
|
||||
},
|
||||
async convertJSON(data) {
|
||||
if(!data.ok)
|
||||
return Promise.reject({ data, json: await data.json() });
|
||||
@@ -145,5 +180,10 @@ export const api = {
|
||||
apiLocation = "/admin/api";
|
||||
|
||||
return apiLocation + "/" + endpoint;
|
||||
},
|
||||
credentialType() {
|
||||
// Development API requests use a different origin (pi.hole) since it is running off of the developer's machine.
|
||||
// Therefore, allow credentials to be used across origins when in development mode.
|
||||
return config.developmentMode ? "include" : "same-origin";
|
||||
}
|
||||
};
|
||||
+17
-10
@@ -8,7 +8,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import React from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import SummaryStats from '../components/SummaryStats';
|
||||
import QueriesGraph from '../components/QueriesGraph';
|
||||
import QueryTypesOverTime from '../components/QueryTypesOverTime';
|
||||
@@ -16,19 +16,26 @@ import ForwardDestOverTime from '../components/ForwardDestOverTime';
|
||||
import TopDomains from '../components/TopDomains';
|
||||
import TopBlocked from '../components/TopBlocked';
|
||||
import TopClients from '../components/TopClients';
|
||||
import { api } from "../utils";
|
||||
|
||||
export default () => (
|
||||
<div className="animated fadeIn">
|
||||
<SummaryStats/>
|
||||
<QueriesGraph/>
|
||||
<div className="row">
|
||||
<QueryTypesOverTime/>
|
||||
<ForwardDestOverTime/>
|
||||
</div>
|
||||
<div className="row">
|
||||
<TopDomains/>
|
||||
<TopBlocked/>
|
||||
<TopClients/>
|
||||
</div>
|
||||
{
|
||||
api.loggedIn ?
|
||||
<Fragment>
|
||||
<div className="row">
|
||||
<QueryTypesOverTime/>
|
||||
<ForwardDestOverTime/>
|
||||
</div>
|
||||
<div className="row">
|
||||
<TopDomains/>
|
||||
<TopBlocked/>
|
||||
<TopClients/>
|
||||
</div>
|
||||
</Fragment>
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
);
|
||||
|
||||
+76
-59
@@ -8,39 +8,77 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import sha from 'sha.js';
|
||||
import { api } from "../utils";
|
||||
import logo from '../img/logo.svg';
|
||||
import routes from "../routes";
|
||||
import ForgotPassword from "../components/ForgotPassword";
|
||||
|
||||
export default class Login extends Component {
|
||||
state = {
|
||||
password: '',
|
||||
error: false,
|
||||
forgotPasswordCollapsed: true
|
||||
cookiesEnabled: false
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
// Check if cookies are enabled
|
||||
if(navigator.cookieEnabled)
|
||||
this.setState({ cookiesEnabled: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user types into the password box.
|
||||
* If they clicked Enter, try to authenticate them.
|
||||
* Otherwise update the password in the state.
|
||||
*
|
||||
* @param e the event
|
||||
*/
|
||||
handlePasswordChange = e => {
|
||||
if(e.keyCode === 13) {
|
||||
this.onAuth();
|
||||
}
|
||||
if(e.keyCode === 13)
|
||||
this.authenticate();
|
||||
else
|
||||
this.setState({ password: e.target.value })
|
||||
};
|
||||
|
||||
onAuth = () => {
|
||||
this.setState({ password: '' });
|
||||
/**
|
||||
* Try to authenticate the user
|
||||
*/
|
||||
authenticate = () => {
|
||||
// Hash the password twice before sending to the API
|
||||
let hashedPassword = sha("sha256").update(this.state.password).digest("hex");
|
||||
hashedPassword = sha("sha256").update(hashedPassword).digest("hex");
|
||||
|
||||
// TODO: Authenticate against server
|
||||
let auth = false;
|
||||
// Clear the state
|
||||
this.setState({ password: '', error: false });
|
||||
|
||||
if(auth) {
|
||||
// Send the password to the API to authenticate the user
|
||||
api.authenticate(hashedPassword)
|
||||
.then(data => {
|
||||
// Verify status
|
||||
if(data.status !== "success") {
|
||||
console.log("Failed to log in:");
|
||||
console.log(data);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.setState({ error: true });
|
||||
}
|
||||
api.loggedIn = true;
|
||||
|
||||
// Redirect to the page the user was originally going to, or if that doesn't exist, go to home
|
||||
const redirect = this.props.location.state.from || '/';
|
||||
this.props.history.push(redirect);
|
||||
})
|
||||
// If there was an error, tell the user they used the wrong password
|
||||
.catch(() => this.setState({ error: true }));
|
||||
};
|
||||
|
||||
render() {
|
||||
// If the user is already logged in, then go to the home page
|
||||
if(api.loggedIn)
|
||||
return <Redirect to="/"/>;
|
||||
|
||||
return (
|
||||
<div className="mainbox col-md-8 offset-md-2 col-lg-6 offset-lg-3" style={{'float': 'none'}}>
|
||||
<div className="card">
|
||||
@@ -57,10 +95,26 @@ export default class Login extends Component {
|
||||
</div>
|
||||
<p className="login-box-msg">
|
||||
Sign in to start your session
|
||||
{
|
||||
// If the user tried to go to a protected page and is not logged in,
|
||||
// tell them they will be redirected once login is successful
|
||||
this.props.location.state && this.props.location.state.from.pathname in routes ?
|
||||
(
|
||||
<Fragment>
|
||||
<br/>
|
||||
You will be transferred to the {routes[this.props.location.state.from.pathname]}
|
||||
</Fragment>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
// If cookies are not enabled (or detected), show a warning
|
||||
!this.state.cookiesEnabled ?
|
||||
<div className="text-center" style={{'color': '#F00'}}>
|
||||
Verify that cookies are allowed for <code>{window.location.host}</code>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
</p>
|
||||
<div id="cookieInfo" className="card-title text-center" style={{'color': '#F00', 'fontSize': '150%'}} hidden>
|
||||
Verify that cookies are allowed for <code>{window.location.host}</code>
|
||||
</div>
|
||||
{
|
||||
this.state.error
|
||||
?
|
||||
@@ -69,8 +123,7 @@ export default class Login extends Component {
|
||||
<i className="fa fa-times-circle-o"/> Wrong password!
|
||||
</label>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -82,51 +135,15 @@ export default class Login extends Component {
|
||||
placeholder="Password" autoFocus/>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-8">
|
||||
<ul style={{'paddingLeft': '10px'}}>
|
||||
<li><samp>Return</samp> → Log in</li>
|
||||
<li><samp>Ctrl+Return</samp> → Log in and go to Settings page</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="col-4">
|
||||
<button type="submit" href="#" className="btn btn-primary pull-right" onClick={this.onAuth}>
|
||||
<div className="col-12">
|
||||
<button type="submit" className="btn btn-primary float-right" style={{'cursor': 'pointer'}}
|
||||
onClick={this.authenticate}>
|
||||
Log in
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div className="row">
|
||||
<div style={{'width': '100%'}}>
|
||||
<div className={'card ' + (this.state.error ? 'border-danger': 'border-primary collapsed-card')}>
|
||||
<div className={'card-header ' + (this.state.error ? 'bg-danger' : 'bg-primary')}
|
||||
style={{'paddingRight': '10px', 'paddingBottom': "0px"}}>
|
||||
<h3 className="card-title" style={{'fontSize': '18px', 'display': 'inline-block', 'margin': 0}}>
|
||||
Forgot password
|
||||
</h3>
|
||||
|
||||
<span className="pull-right">
|
||||
<button type="button" className="btn btn-card-tool"
|
||||
style={{ 'cursor': 'pointer', 'padding': '10px' }} onClick={() => {
|
||||
console.log("click");
|
||||
this.setState({
|
||||
forgotPasswordCollapsed: !this.state.forgotPasswordCollapsed
|
||||
})
|
||||
}}>
|
||||
<i className={'fa ' + (!this.state.forgotPasswordCollapsed !== this.state.error ? 'fa-minus' : 'fa-plus')}/>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<div id="forgotPassword"
|
||||
className={'card-body bg-light' + (this.state.forgotPasswordCollapsed !== this.state.error ? ' collapse' : '')}
|
||||
style={{'padding': '10px'}}>
|
||||
After installing Pi-hole for the first time, a password is generated and displayed to the user.
|
||||
The password cannot be retrieved later on, but it is possible to set a new password (or
|
||||
explicitly disable the password by setting an empty password) using the command:
|
||||
<pre style={{'textAlign': 'center'}}>sudo pihole -a -p</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ForgotPassword error={this.state.error}/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* Web Interface
|
||||
* Logout the user
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { api } from "../utils";
|
||||
|
||||
export default class Logout extends Component {
|
||||
componentWillMount() {
|
||||
api.loggedIn = false;
|
||||
api.logout();
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Redirect to="/"/>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user