Esempio n. 1
0
 public function reg()
 {
     if ($this->validate()) {
         $modelUser = new User();
         $modelUser->phone = $this->getPhoneNumber();
         $modelUser->email = $this->email;
         $modelUser->status = $this->status;
         $modelUser->country_id = $this->country_id;
         $modelUser->setPassword($this->password);
         $modelUser->generateAuthKey();
         if ($this->scenario === 'emailActivation') {
             $modelUser->generateSecretKey();
         }
         if ($modelUser->save()) {
             $modelUserProfile = new UserProfile();
             $modelUserProfile->link('user', $modelUser);
             $modelUserPrivilege = new UserPrivilege();
             $modelUserPrivilege->link('user', $modelUser);
             return RbacHelper::assignRole($modelUser->getId()) ? $modelUser : null;
         }
     }
     return false;
 }