public function actionAdd() { $registration = new Registration(); $registration->enableEmailField = true; $registration->enableUserApproval = false; if ($registration->submitted('save') && $registration->validate() && $registration->register()) { return $this->redirect(['edit', 'id' => $registration->getUser()->id]); } return $this->render('add', array('hForm' => $registration)); }
/** * @param \yii\authclient\BaseClient $authClient * @param Registration $registration * @return boolean already all registration data gathered * @throws Exception */ protected function handleAuthClientRegistration(ClientInterface $authClient, Registration $registration) { $attributes = $authClient->getUserAttributes(); if (!isset($attributes['id'])) { throw new Exception("No user id given by authclient!"); } $registration->enablePasswordForm = false; if ($authClient instanceof ApprovalBypass) { $registration->enableUserApproval = false; } // do not store id attribute unset($attributes['id']); $registration->getUser()->setAttributes($attributes, false); $registration->getProfile()->setAttributes($attributes, false); }