mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-29 17:26:40 +01:00
Logout is one step now
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# v1.6.7
|
# v1.6.7
|
||||||
## xx/xx/2017
|
## xx/xx/2017
|
||||||
|
|
||||||
|
1. [](#new)
|
||||||
|
* Logout of admin goes straight to login form with a message (that then fades out)
|
||||||
1. [](#improved)
|
1. [](#improved)
|
||||||
* Added code to use new `GPM::loadRemoteGrav` if it exists in Gav [grav#1746](https://github.com/getgrav/grav/pull/1746)
|
* 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)
|
* Add vertical style for order field [#1253](https://github.com/getgrav/grav-plugin-admin/pull/1253)
|
||||||
|
|||||||
@@ -527,6 +527,12 @@ class AdminPlugin extends Plugin
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$flashData = $this->grav['session']->getFlashCookieObject(Admin::TMP_COOKIE_NAME);
|
||||||
|
|
||||||
|
if (isset($flashData->message)) {
|
||||||
|
$this->grav['messages']->add($flashData->message, $flashData->status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ define('LOGIN_REDIRECT_COOKIE', 'grav-login-redirect');
|
|||||||
class Admin
|
class Admin
|
||||||
{
|
{
|
||||||
const MEDIA_PAGINATION_INTERVAL = 20;
|
const MEDIA_PAGINATION_INTERVAL = 20;
|
||||||
|
const TMP_COOKIE_NAME = 'tmp-admin-message';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Grav
|
* @var Grav
|
||||||
|
|||||||
@@ -691,10 +691,12 @@ class AdminController extends AdminBaseController
|
|||||||
*/
|
*/
|
||||||
protected function taskLogout()
|
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->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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
---
|
|
||||||
@@ -31,6 +31,12 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready( function() {
|
||||||
|
$('#messages').delay(5000).animate({ height: 'toggle', opacity: 'toggle' }, 'slow');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -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 %}
|
|
||||||
Reference in New Issue
Block a user