/** * Main action. * * @return void * https://five-devshop.myharavan.com/admin/api/auth/?api_key=2f473d7bb160533c9535985ff068cc56 * @Route("/", methods={"GET", "POST"}, name="login-user-index") */ public function indexAction() { if ($this->session->get('me')) { return $this->response->redirect('home'); } $redirectUrl = base64_decode($this->request->getQuery('redirect', null, '')); if (strlen($redirectUrl) > 0) { $parts = parse_url($redirectUrl); parse_str($parts['query'], $query); $shopName = $query['shop']; } $formData = []; $cookie = false; $formData['fname'] = $this->request->getPost('fname', null, ''); $formData['fpassword'] = $this->request->getPost('fpassword', null, ''); $formData['fcookie'] = $this->request->getPost('fcookie', null, false); if ($this->request->hasPost('fsubmit')) { if ($this->security->checkToken()) { if (isset($formData['fcookie']) && $formData['fcookie'] == 'remember-me') { $cookie = (bool) true; } $identity = $this->check((string) $formData['fname'], (string) $formData['fpassword'], $cookie, true); if ($identity == true) { $myApp = AppModel::findFirst(1); if ($redirectUrl != null) { return $this->response->redirect($redirectUrl, true, 301); } else { return $this->response->redirect('https://' . $shopName . '/admin/api/auth/?api_key=' . $myApp->apiKey, true, 301); } } } } $this->tag->prependTitle('Login'); $this->view->setVars(['formData' => $formData]); }