예제 #1
0
 public function testCreateAuthWithRole()
 {
     $auth = new Auth(array('email' => "*****@*****.**", 'password' => 'teste', 'name' => "User", 'role' => "admin"));
     $auth->setTrustedAction(true);
     $auth->save();
     $this->assertTrue($auth->role == null);
     Context::setTrusted(true);
     $auth = new Auth(array('email' => "*****@*****.**", 'password' => 'teste', 'name' => "User", 'role' => "admin"));
     $auth->setTrustedAction(true);
     $auth->save();
     $this->assertTrue($auth->role == "admin");
 }
예제 #2
0
 public function register()
 {
     $data = $this->getData();
     $this->validateParams($data);
     if (Auth::where('email', $data['email'])->first()) {
         throw new Exceptions\InternalException('already_registered');
     }
     // let's create a new authentication
     $auth = new Auth();
     $auth->setTrustedAction(true);
     // set email/password directly due mass-assignment prevention
     $auth->email = $data['email'];
     $auth->password = $data['password'];
     // fill with additional auth-data
     $auth->fill($data);
     $auth->save();
     return $auth->dataWithToken();
 }