Improve login page
This commit is contained in:
@@ -20,6 +20,7 @@ export interface AdminLoginPageState {
|
||||
error: string;
|
||||
}
|
||||
|
||||
const DEFAULT_REDIRECT = "/admin";
|
||||
class AdminLoginPage extends React.Component<AdminLoginPageProps, AdminLoginPageState> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -90,13 +91,14 @@ class AdminLoginPage extends React.Component<AdminLoginPageProps, AdminLoginPage
|
||||
const { search } = location;
|
||||
const params = qs.parse(search);
|
||||
const { next } = params;
|
||||
return next || "/admin";
|
||||
return next || DEFAULT_REDIRECT;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { username, password, isAuthenticated } = this.state;
|
||||
const next = this.getRedirectURL();
|
||||
|
||||
if (isAuthenticated) {
|
||||
const next = this.getRedirectURL();
|
||||
return <Redirect to={next} />;
|
||||
}
|
||||
|
||||
@@ -105,6 +107,9 @@ class AdminLoginPage extends React.Component<AdminLoginPageProps, AdminLoginPage
|
||||
<Helmet>
|
||||
<link rel="canonical" href="https://sik.ayy.fi/admin/login" />
|
||||
</Helmet>
|
||||
{ next && next !== DEFAULT_REDIRECT && (
|
||||
<div>You have to log in first.</div>
|
||||
) }
|
||||
<form className="admin-login-form" onSubmit={this.handleSubmit}>
|
||||
<label>Username
|
||||
<input id="login-username" type="text" name="username" value={username} onChange={this.handleUserNameChange} />
|
||||
|
||||
Reference in New Issue
Block a user