frontend/models/SignupForm.php
/**
     * Signs user up.
     *
     * @return bool whether the creating new account was successful and email was sent
     */
Signs user up.
@return bool whether the creating new account was successful and email was sent
Signs user up . @return bool whether the creating new account was successful and email was sent
public function signup()
    {
        if (!$this->validate()) {
            return null;
        }
        $user = new User();
        $profile = new Profiles();
        $user->username = $this->username;
        $user->email = $this->email;
        $user->setPassword($this->password);
        $user->generateAuthKey();
        $user->status = 10;
        $user->save(false);
        $profile->userId = $user->getId();
        $profile->alergias = $this->alergias;
        $profile->telefone = $this->telefone;
        $profile->morada = $this->morada;
        $profile->genero = $this->genero;
        $profile->fullname = $this->fullname;
        $profile->age = $this->age;
        $profile->save(false);
        $auth = \Yii::$app->authManager;
        $authorRole = $auth->getRole('user');
        $auth->assign($authorRole, $user->getId());
        return $user->save();
    }
public function signup ( ) { if ( ! $ this -> validate ( ) ) { return null ; } $ user = new User ( ) ; $ profile = new Profiles ( ) ; $ user -> username = $ this -> username ; $ user -> email = $ this -> email ; $ user -> setPassword ( $ this -> password ) ; $ user -> generateAuthKey ( ) ; $ user -> status = 10 ; $ user -> save ( false ) ; $ profile -> userId = $ user -> getId ( ) ; $ profile -> alergias = $ this -> alergias ; $ profile -> telefone = $ this -> telefone ; $ profile -> morada = $ this -> morada ; $ profile -> genero = $ this -> genero ; $ profile -> fullname = $ this -> fullname ; $ profile -> age = $ this -> age ; $ profile -> save ( false ) ; $ auth = \ Yii :: $ app -> authManager ; $ authorRole = $ auth -> getRole ( 'user' ) ; $ auth -> assign ( $ authorRole , $ user -> getId ( ) ) ; return $ user -> save ( ) ; }
Signs user up.
Signs user up .
// $user->generateEmailVerificationToken(); //Comentei para não termos que nos preocupar com email verifications //O status fica a 10 que significa que já confirmou o mail.