frontend/models/SignupForm.php
/**
     * Signs user up.
     *
     * @return User|null the saved model or null if saving fails
     */
Signs user up.
@return User|null the saved model or null if saving fails
Signs user up . @return User|null the saved model or null if saving fails
public function signup()
    {
        if (!$this->validate()) {
            return null;
        }
        $user = new User();
        $user->first_name = $this->first_name;
        $user->last_name = $this->last_name;
        $user->username = $this->username;
        $user->email = $this->email;
        $user->setPassword($this->password);
        $user->generateAuthKey();
        $res= $user->save() ? $user : null;
        if ($res!=null){
            $permissionList = $_POST['SignupForm']['permissions'];
            foreach ($permissionList as $value){
                $newPermission =new AuthAssignment;
                $newPermission ->user_id = $user->id;
                $newPermission->item_name = $value;
                $newPermission->save();
            }
        }  
         return $res;
    }
public function signup ( ) { if ( ! $ this -> validate ( ) ) { return null ; } $ user = new User ( ) ; $ user -> first_name = $ this -> first_name ; $ user -> last_name = $ this -> last_name ; $ user -> username = $ this -> username ; $ user -> email = $ this -> email ; $ user -> setPassword ( $ this -> password ) ; $ user -> generateAuthKey ( ) ; $ res = $ user -> save ( ) ? $ user : null ; if ( $ res != null ) { $ permissionList = $ _POST [ 'SignupForm' ] [ 'permissions' ] ; foreach ( $ permissionList as $ value ) { $ newPermission = new AuthAssignment ; $ newPermission -> user_id = $ user -> id ; $ newPermission -> item_name = $ value ; $ newPermission -> save ( ) ; } } return $ res ; }
Signs user up.
Signs user up .
// lets add the permissions