Auth->allow(['validateAccount', 'resendValidation']); } /** * Validates social account * * @param string $provider provider * @param string $reference reference * @param string $token token * @return Response */ public function validateAccount($provider, $reference, $token) { try { $result = $this->SocialAccounts->validateAccount($provider, $reference, $token); if ($result) { $this->Flash->success(__d('CakeDC/Users', 'Account validated successfully')); } else { $this->Flash->error(__d('CakeDC/Users', 'Account could not be validated')); } } catch (RecordNotFoundException $exception) { $this->Flash->error(__d('CakeDC/Users', 'Invalid token and/or social account')); } catch (AccountAlreadyActiveException $exception) { $this->Flash->error(__d('CakeDC/Users', 'Social Account already active')); } catch (\Exception $exception) { $this->Flash->error(__d('CakeDC/Users', 'Social Account could not be validated')); } return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']); } /** * Resends validation email if required * * @param string $provider provider * @param string $reference reference * @return mixed * @throws AccountAlreadyActiveException */ public function resendValidation($provider, $reference) { try { $result = $this->SocialAccounts->resendValidation($provider, $reference); if ($result) { $this->Flash->success(__d('CakeDC/Users', 'Email sent successfully')); } else { $this->Flash->error(__d('CakeDC/Users', 'Email could not be sent')); } } catch (RecordNotFoundException $exception) { $this->Flash->error(__d('CakeDC/Users', 'Invalid account')); } catch (AccountAlreadyActiveException $exception) { $this->Flash->error(__d('CakeDC/Users', 'Social Account already active')); } catch (\Exception $exception) { $this->Flash->error(__d('CakeDC/Users', 'Email could not be resent')); } return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']); } }