Logout is one step now

This commit is contained in:
Andy Miller
2017-12-01 16:08:52 -07:00
parent dcea3f9889
commit 1b97769ea5
7 changed files with 19 additions and 36 deletions

View File

@@ -1,6 +1,8 @@
# v1.6.7
## xx/xx/2017
1. [](#new)
* Logout of admin goes straight to login form with a message (that then fades out)
1. [](#improved)
* Added code to use new `GPM::loadRemoteGrav` if it exists in Gav [grav#1746](https://github.com/getgrav/grav/pull/1746)
* Add vertical style for order field [#1253](https://github.com/getgrav/grav-plugin-admin/pull/1253)

View File

@@ -527,6 +527,12 @@ class AdminPlugin extends Plugin
break;
}
$flashData = $this->grav['session']->getFlashCookieObject(Admin::TMP_COOKIE_NAME);
if (isset($flashData->message)) {
$this->grav['messages']->add($flashData->message, $flashData->status);
}
}
/**

View File

@@ -34,6 +34,7 @@ define('LOGIN_REDIRECT_COOKIE', 'grav-login-redirect');
class Admin
{
const MEDIA_PAGINATION_INTERVAL = 20;
const TMP_COOKIE_NAME = 'tmp-admin-message';
/**
* @var Grav

View File

@@ -691,10 +691,12 @@ class AdminController extends AdminBaseController
*/
protected function taskLogout()
{
$language = $this->grav['user']->authenticated ? $this->grav['user']->language : ($this->grav['language']->getLanguage() ?: 'en');
$message = $this->admin->translate('PLUGIN_ADMIN.LOGGED_OUT');
$this->admin->session()->invalidate()->start();
$this->setRedirect('/logout/lang:' . $language);
$this->grav['session']->setFlashCookieObject(Admin::TMP_COOKIE_NAME, ['message' => $message, 'status' => 'info']);
$this->setRedirect('/');
return true;
}

View File

@@ -1,14 +0,0 @@
---
title: Dashboard Logout
form:
fields:
- name: username
type: text
placeholder: PLUGIN_ADMIN.USERNAME
autofocus: true
- name: password
type: password
placeholder: PLUGIN_ADMIN.PASSWORD
---

View File

@@ -31,6 +31,12 @@
{% endif %}
</div>
<script>
$(document).ready( function() {
$('#messages').delay(5000).animate({ height: 'toggle', opacity: 'toggle' }, 'slow');
});
</script>
{% endif %}
{% endblock %}

View File

@@ -1,20 +0,0 @@
{% embed 'partials/login.html.twig' with {title:'Grav Logout'} %}
{% block head %}
{{ parent() }}
<meta http-equiv="refresh" content="3; URL={{ base_url_relative }}">
{% endblock %}
{% block messages %}{% endblock %}
{% block body %}
<body id="admin-login-wrapper">
<section id="admin-login" class="default-box-shadow ">
<h1>
{{ title }}
</h1>
{{ admin.setMessage('PLUGIN_ADMIN.LOGGED_OUT'|tu(uri.param('lang'))) }}
{% include 'partials/messages.html.twig' %}
</section>
</body>
{% endblock %}
{% endembed %}