File tree Expand file tree Collapse file tree 6 files changed +26
-3
lines changed Expand file tree Collapse file tree 6 files changed +26
-3
lines changed Original file line number Diff line number Diff line change
1
+ // POST logout action
2
+
3
+ const logoutButton = function ( ) {
4
+ const logoutForm = document . querySelector ( '[data-logout-form]' )
5
+
6
+ if ( ! logoutForm ) return
7
+
8
+ document . body . addEventListener ( 'click' , e => {
9
+ if ( e . target . hasAttribute ( 'data-logout-btn' ) ) {
10
+ e . preventDefault ( )
11
+ logoutForm . submit ( )
12
+ }
13
+ } )
14
+ }
15
+
16
+ export default logoutButton
Original file line number Diff line number Diff line change @@ -4,12 +4,14 @@ import 'styles/app.scss'
4
4
import Vue from 'vue'
5
5
import navToggle from '@/behaviors/navToggle'
6
6
import showEnvLine from '@/behaviors/showEnvLine'
7
+ import logoutButton from '@/behaviors/logoutButton'
7
8
import search from '@/main-search'
8
9
import merge from 'lodash/merge'
9
10
10
11
const A17Init = function ( ) {
11
12
navToggle ( )
12
13
showEnvLine ( )
14
+ logoutButton ( )
13
15
}
14
16
15
17
// User header dropdown
Original file line number Diff line number Diff line change 5
5
if (config ('twill.enabled.users-management ' )) {
6
6
Route::get ('login ' , 'LoginController@showLoginForm ' )->name ('login.form ' );
7
7
Route::post ('login ' , 'LoginController@login ' )->name ('login ' );
8
- Route::get ('logout ' , 'LoginController@logout ' )->name ('logout ' );
8
+ Route::post ('logout ' , 'LoginController@logout ' )->name ('logout ' );
9
9
10
10
Route::get ('password/reset ' , 'ForgotPasswordController@showLinkRequestForm ' )->name ('password.reset.link ' );
11
11
Route::post ('password/email ' , 'ForgotPasswordController@sendResetLinkEmail ' )->name ('password.reset.email ' );
Original file line number Diff line number Diff line change 71
71
@include (' twill::partials.footer' )
72
72
</section >
73
73
</div >
74
+
75
+ <form class =" visually-hidden" method =" POST" action =" {{ route (' admin.logout' ) } }" data-logout-form >
76
+ @csrf
77
+ </form >
78
+
74
79
<script >
75
80
window [' {{ config (' twill.js_namespace' ) } }' ] = {};
76
81
window [' {{ config (' twill.js_namespace' ) } }' ].version = ' {{ config (' twill.version' ) } }' ;
Original file line number Diff line number Diff line change 22
22
@if (isset ($currentUser ) )
23
23
<a href =" {{ route (' admin.users.index' ) } }" >{{ twillTrans (' twill::lang.nav.cms-users' ) } } </a ><br />
24
24
<a href =" {{ route (' admin.users.edit' , $currentUser -> id ) } }" >{{ twillTrans (' twill::lang.nav.settings' ) } } </a ><br />
25
- <a href =" {{ route ( ' admin. logout' ) } } " >{{ twillTrans (' twill::lang.nav.logout' ) } } </a >
25
+ <a href =" # " data- logout-btn >{{ twillTrans (' twill::lang.nav.logout' ) } } </a >
26
26
@endif
27
27
</div >
28
28
</div >
Original file line number Diff line number Diff line change 14
14
<a href =" {{ route (' admin.users.index' ) } }" >{{ twillTrans (' twill::lang.nav.cms-users' ) } } </a >
15
15
@endcan
16
16
<a href =" {{ route (' admin.users.edit' , $currentUser -> id ) } }" >{{ twillTrans (' twill::lang.nav.settings' ) } } </a >
17
- <a href =" {{ route ( ' admin. logout' ) } } " >{{ twillTrans (' twill::lang.nav.logout' ) } } </a >
17
+ <a href =" # " data- logout-btn >{{ twillTrans (' twill::lang.nav.logout' ) } } </a >
18
18
</div >
19
19
</a17-dropdown >
20
20
@endif
You can’t perform that action at this time.
0 commit comments