登录后固定进入首页,不再回跳上次打开的业务页面
- 账号密码登录与钉钉免登都忽略 url.intended,直接进 landing_page(首页/财务驾驶舱) - 补充登录落地测试,修正首页改版后仍按旧行为断言的测试
This commit is contained in:
parent
9f4f4f0cbb
commit
566a3ef4db
@ -157,7 +157,10 @@ class DingTalkLogin extends Controller
|
||||
|
||||
$url = $this->applicationRoute($user->landing_page, ['company_id' => $company->id]);
|
||||
|
||||
return redirect()->intended($url);
|
||||
// 免登后固定回到首页(财务驾驶舱),不再回跳上次打开的业务页面。
|
||||
$request->session()->forget('url.intended');
|
||||
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
protected function failed(): RedirectResponse
|
||||
|
||||
@ -107,8 +107,11 @@ class Login extends Controller
|
||||
// Redirect to landing page if is user
|
||||
$url = route($user->landing_page, ['company_id' => $company->id]);
|
||||
|
||||
// 登录后固定回到首页(财务驾驶舱),不再回跳上次打开/被拦截的业务页面。
|
||||
$request->session()->forget('url.intended');
|
||||
|
||||
if (! $request->expectsJson()) {
|
||||
return redirect()->intended($url);
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
@ -117,7 +120,7 @@ class Login extends Controller
|
||||
'error' => false,
|
||||
'message' => trans('auth.login_redirect'),
|
||||
'data' => null,
|
||||
'redirect' => redirect()->intended($url)->getTargetUrl(),
|
||||
'redirect' => url($url),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +143,8 @@ class DingTalkLoginTest extends FeatureTestCase
|
||||
$this->get(route('login.dingtalk.callback', ['code' => 'fixture', 'state' => $state]))
|
||||
->assertRedirect(route('dashboard', ['company_id' => $this->company->id]));
|
||||
$this->get(route('dashboard', ['company_id' => $this->company->id]))
|
||||
->assertRedirectContains('/workspace/courier-payables/courier-quote');
|
||||
->assertOk()
|
||||
->assertSee('data-cockpit', false);
|
||||
|
||||
$created = auth()->user();
|
||||
$this->assertSame('dingtalk_roster_limited', $created->created_from);
|
||||
|
||||
@ -148,6 +148,25 @@ class UsersTest extends FeatureTestCase
|
||||
$this->isAuthenticated($user->user);
|
||||
}
|
||||
|
||||
public function testItShouldLandOnTheHomePageAfterLoginInsteadOfTheLastOpenedBusinessPage()
|
||||
{
|
||||
// 未登录访问业务页面时,框架会记录 intended;登录后不应该再回跳到该页面。
|
||||
$this->withExceptionHandling()->get(route('business.pages.show', [
|
||||
'company_id' => $this->company->id,
|
||||
'section' => 'courier-payables',
|
||||
'page' => 'freight-reconciliation',
|
||||
]));
|
||||
|
||||
$response = $this->post(route('login'), [
|
||||
'email' => $this->user->email,
|
||||
'password' => '123456',
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertTrue(auth()->check());
|
||||
$this->assertStringNotContainsString('/workspace/', (string) $response->headers->get('Location'));
|
||||
}
|
||||
|
||||
public function testItShouldNotLoginUser()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
@ -68,7 +68,7 @@ class UserAccessGroupsTest extends FeatureTestCase
|
||||
$this->loginAs()->patch(route('system-settings.sidebar.update'), ['subject' => 'group_'.$b->id, 'permissions' => []])
|
||||
->assertRedirect(route('system-settings.sidebar.edit', ['subject' => 'group_'.$b->id]));
|
||||
$this->assertSame(['store-management/basic-information'], SidebarPermissions::allowedKeys($member));
|
||||
$this->loginAs($member)->get(route('dashboard'))->assertRedirectContains('/workspace/store-management/basic-information');
|
||||
$this->loginAs($member)->get(route('dashboard'))->assertOk()->assertSee('data-cockpit', false);
|
||||
}
|
||||
|
||||
public function test_user_override_can_be_empty_and_can_restore_group_inheritance(): void
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user