Ejemplo n.º 1
0
 public function testTrustedCanUpdateRole()
 {
     Context::setTrusted(true);
     $auth = Auth::where('email', "*****@*****.**")->first();
     $auth->role = "admin";
     $auth->setTrustedAction(true);
     $auth->save();
     $this->assertTrue($auth->role == "admin");
 }
Ejemplo n.º 2
0
 /**
  * Reset auth password
  */
 public function resetPassword()
 {
     $data = $this->getData();
     if (!isset($data['token']) === 0) {
         throw new Exceptions\BadRequestException("you must provide a 'token'.");
     }
     if (!isset($data['password']) || strlen($data['password']) === 0) {
         throw new Exceptions\BadRequestException("you must provide a valid 'password'.");
     }
     // Set trusted context to update auths row
     Context::setTrusted(true);
     $auth = Auth::where(Auth::FORGOT_PASSWORD_FIELD, $data['token'])->first();
     if ($auth && $auth->resetPassword($data['password'])) {
         return array('success' => true);
     } else {
         throw new Exceptions\UnauthorizedException("invalid_token");
     }
 }