function getActivateAction(ActivateUser $activateUserCommand, Router $router, Users $eUsers, Response $response) { $rUser = $eUsers->where('activation', $router->get('activation'))->oneOrFail(new NotFound('User not found. Maybe it was already activated?')); return $activateUserCommand->setUser($rUser)->onSuccess(function () use($response) { $response->redirect('/auth/activated?succesful'); })->onError(function () { return view('vendor/lfw/auth/src/Pckg/Auth/View/activationFailed'); })->execute(); }
/** * * @param type $id * @return type * @throws BadRequestHttpException */ public function actionActivate($id) { $user = $this->findModel($id); $token = $user->activate_token; if ($token !== null) { try { $model = new ActivateUser($token); } catch (InvalidParamException $e) { throw new BadRequestHttpException($e->getMessage()); } if ($model->activate()) { Yii::$app->getSession()->setFlash('success', 'User activated !'); return $this->redirect(['index']); } else { Yii::$app->getSession()->setFlash('error', 'activation incomplete !.'); return $this->redirect(['index']); } } else { Yii::$app->getSession()->setFlash('error', 'user already active !.'); return $this->redirect(['index']); } }