Fix redirecting without URL query string after logged in
This commit is contained in:
parent
bb719bd089
commit
718c7a61a5
@ -59,7 +59,9 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
Cache::forget($loginFailsCacheKey);
|
Cache::forget($loginFailsCacheKey);
|
||||||
|
|
||||||
return json(trans('auth.login.success'), 0);
|
return json(trans('auth.login.success'), 0, [
|
||||||
|
'redirectTo' => $request->session()->pull('last_requested_path', url('/user')),
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
// Increase the counter
|
// Increase the counter
|
||||||
Cache::put($loginFailsCacheKey, ++$loginFails, 3600);
|
Cache::put($loginFailsCacheKey, ++$loginFails, 3600);
|
||||||
|
@ -10,7 +10,7 @@ class Authenticate extends Middleware
|
|||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
if (! $request->expectsJson()) {
|
||||||
session([
|
session([
|
||||||
'last_requested_path' => $request->path(),
|
'last_requested_path' => $request->fullUrl(),
|
||||||
'msg' => trans('auth.check.anonymous'),
|
'msg' => trans('auth.check.anonymous'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default {
|
|||||||
|
|
||||||
this.pending = true
|
this.pending = true
|
||||||
const {
|
const {
|
||||||
code, message, data: { login_fails: loginFails } = { login_fails: 0 },
|
code, message, data: { login_fails: loginFails, redirectTo } = { login_fails: 0 },
|
||||||
} = await this.$http.post(
|
} = await this.$http.post(
|
||||||
'/auth/login',
|
'/auth/login',
|
||||||
{
|
{
|
||||||
@ -103,9 +103,7 @@ export default {
|
|||||||
)
|
)
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
this.$message.success(message)
|
this.$message.success(message)
|
||||||
setTimeout(() => {
|
setTimeout(() => (window.location = redirectTo), 1000)
|
||||||
window.location = `${blessing.base_url}/${blessing.redirect_to || 'user'}`
|
|
||||||
}, 1000)
|
|
||||||
} else {
|
} else {
|
||||||
if (loginFails > 3 && !this.tooManyFails) {
|
if (loginFails > 3 && !this.tooManyFails) {
|
||||||
if (this.recaptcha) {
|
if (this.recaptcha) {
|
||||||
|
@ -25,7 +25,7 @@ test('login', async () => {
|
|||||||
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
||||||
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
||||||
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
.mockResolvedValueOnce({ code: 1, data: { login_fails: 4 } })
|
||||||
.mockResolvedValueOnce({ code: 0, message: 'ok' })
|
.mockResolvedValueOnce({ code: 0, message: 'ok', data: { redirectTo: '' } })
|
||||||
const wrapper = mount(Login, { stubs: { Captcha } })
|
const wrapper = mount(Login, { stubs: { Captcha } })
|
||||||
const form = wrapper.find('form')
|
const form = wrapper.find('form')
|
||||||
const warning = wrapper.find('.callout-warning')
|
const warning = wrapper.find('.callout-warning')
|
||||||
|
@ -15,3 +15,4 @@
|
|||||||
- Fixed renaming item in closet.
|
- Fixed renaming item in closet.
|
||||||
- Fixed Font Awesome of bottom of home page.
|
- Fixed Font Awesome of bottom of home page.
|
||||||
- Fixed loading front-end i18n texts of plugins.
|
- Fixed loading front-end i18n texts of plugins.
|
||||||
|
- Fixed redirecting without URL query string after logged in.
|
||||||
|
@ -15,3 +15,4 @@
|
|||||||
- 修复不能重命名衣柜物品的问题
|
- 修复不能重命名衣柜物品的问题
|
||||||
- 修复首页底部 Font Awesome 的问题
|
- 修复首页底部 Font Awesome 的问题
|
||||||
- 修复插件系统中加载前端国际化文本的问题
|
- 修复插件系统中加载前端国际化文本的问题
|
||||||
|
- 修复登录重定向没有包含 URL 查询的问题
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
@include('common.seo-meta-tags')
|
@include('common.seo-meta-tags')
|
||||||
<!-- App Styles -->
|
<!-- App Styles -->
|
||||||
@include('common.dependencies.style')
|
@include('common.dependencies.style')
|
||||||
|
|
||||||
<script>blessing.redirect_to = "{{ session('last_requested_path') }}";</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="hold-transition login-page">
|
<body class="hold-transition login-page">
|
||||||
|
Loading…
Reference in New Issue
Block a user