backend/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();
        $user->username = $this->username;
        $user->email = $this->email;
        $user->setPassword($this->password);
        $user->generateAuthKey();
        $user->status = 10;
        $user->save(false);
        $staff = new Staff();
        $staff->userId = $user->getId();
        $staff->restaurantId = $this->restaurantId;
        $staff->save(false);    
        if($this->roleId){
            $auth = \Yii::$app->authManager;
            $authorRole = $auth->getRole('admin');
            $auth->assign($authorRole, $user->getId());
        }else{
            $auth = \Yii::$app->authManager;
            $authorRole = $auth->getRole('cook');
            $auth->assign($authorRole, $user->getId());
        }
        return $user->save();
    }
public function signup ( ) { if ( ! $ this -> validate ( ) ) { return null ; } $ user = new User ( ) ; $ user -> username = $ this -> username ; $ user -> email = $ this -> email ; $ user -> setPassword ( $ this -> password ) ; $ user -> generateAuthKey ( ) ; $ user -> status = 10 ; $ user -> save ( false ) ; $ staff = new Staff ( ) ; $ staff -> userId = $ user -> getId ( ) ; $ staff -> restaurantId = $ this -> restaurantId ; $ staff -> save ( false ) ; if ( $ this -> roleId ) { $ auth = \ Yii :: $ app -> authManager ; $ authorRole = $ auth -> getRole ( 'admin' ) ; $ auth -> assign ( $ authorRole , $ user -> getId ( ) ) ; } else { $ auth = \ Yii :: $ app -> authManager ; $ authorRole = $ auth -> getRole ( 'cook' ) ; $ 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.
