fix duplicated logout modal (fix #332)
This commit is contained in:
parent
e8ec0c4c0d
commit
79ec6e206a
@ -1,4 +1,3 @@
|
||||
import './i18n'
|
||||
import { getExtraData } from './extra'
|
||||
|
||||
export function scrollHander() {
|
||||
@ -15,19 +14,6 @@ export function scrollHander() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
await fetch(`${blessing.base_url}/auth/logout`, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector<HTMLMetaElement>(
|
||||
'meta[name="csrf-token"]',
|
||||
)!.content,
|
||||
},
|
||||
})
|
||||
window.location.href = blessing.base_url
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
const { transparent_navbar } = getExtraData() as {
|
||||
@ -37,7 +23,3 @@ if (process.env.NODE_ENV !== 'test') {
|
||||
window.addEventListener('load', scrollHander)
|
||||
}
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
document
|
||||
.querySelector<HTMLButtonElement>('#btn-logout')
|
||||
?.addEventListener('click', logout)
|
||||
|
@ -1,22 +1,4 @@
|
||||
import { scrollHander, logout } from '@/scripts/homePage'
|
||||
|
||||
test('logout', async () => {
|
||||
const meta = document.createElement('meta')
|
||||
meta.name = 'csrf-token'
|
||||
meta.content = 'token'
|
||||
document.head.appendChild(meta)
|
||||
|
||||
window.fetch = jest.fn()
|
||||
|
||||
await logout()
|
||||
expect(window.fetch).toBeCalledWith('/auth/logout', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': 'token',
|
||||
},
|
||||
})
|
||||
})
|
||||
import { scrollHander } from '@/scripts/homePage'
|
||||
|
||||
describe('scroll handler', () => {
|
||||
beforeAll(() => {
|
||||
|
@ -128,26 +128,6 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div id="modal-logout" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{{ trans('general.notice') }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{ trans('front-end.general.confirmLogout') }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" data-dismiss="modal">{{ trans('general.cancel') }}</button>
|
||||
<button class="btn btn-primary" id="btn-logout">{{ trans('front-end.general.confirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="application/json" id="blessing-extra">
|
||||
{{ {transparent_navbar: transparent_navbar}|json_encode|raw }}
|
||||
</script>
|
||||
|
@ -31,7 +31,7 @@
|
||||
{% endif %}
|
||||
<div class="dropdown-divider"></div>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="#" id="logout-button" data-toggle="modal" data-target="#modal-logout">
|
||||
<a class="dropdown-item" href="#" id="logout-button">
|
||||
{{ trans('general.logout') }}
|
||||
</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user