| Conditions | 8 |
| Paths | 6 |
| Total Lines | 27 |
| Lines | 21 |
| Ratio | 77.78 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function loginAction(Request $request) |
||
| 18 | { |
||
| 19 | View Code Duplication | if (!$this->isGranted('ROLE_USER')) { |
|
|
|
|||
| 20 | |||
| 21 | /* Save targetpath if user was not logged in yet before redirecting to login page */ |
||
| 22 | if ($request->hasSession() && $request->isMethodSafe(false)) { |
||
| 23 | $referer = $request->headers->get('referer'); |
||
| 24 | if (null !== $referer) { |
||
| 25 | $request->getSession()->set('ddr.gitki.manuallogin.targetpath', $referer); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | throw new AuthenticationException(); |
||
| 30 | } |
||
| 31 | |||
| 32 | View Code Duplication | if ($request->hasSession() && $request->isMethodSafe(false)) { |
|
| 33 | |||
| 34 | /* Restore target path after login */ |
||
| 35 | $targetPath = $request->getSession()->get('ddr.gitki.manuallogin.targetpath'); |
||
| 36 | $request->getSession()->remove('ddr.gitki.manuallogin.targetpath'); |
||
| 37 | if (null !== $targetPath) { |
||
| 38 | return $this->redirect($targetPath); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return $this->redirect($this->generateUrl('ddr_gitki_directory', ['path' => '/', 'action' => 'index'])); |
||
| 43 | } |
||
| 44 | |||
| 53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.