/** * Block an account * * @param $id * @param array $data * @return bool * @throws LowPermissionException */ public function blockAccount($id, array $data) { $account = $this->account->findById($id); if ($account['type'] == 9) { throw new LowPermissionException('You cannot block this account.', ''); } $data['account'] = $id; $wasBanned = $this->account->update(array('id' => $id), array('status' => 'BLOCK', 'availDt' => $data['expiration'])); if ($wasBanned) { $this->app['events']->fire('account.blocked', array($data)); } return $wasBanned; }
/** * Generate a new deletion code and sends it to the email * * @param $user * @return bool * @throws DeletionCodeException */ public function deletionCode($user) { $account = $this->account->findById($user); if (!$account) { throw new DeletionCodeException('This account doesn\'t exists'); } $data = ['id' => $account['id'], 'email' => $account['email'], 'login' => $account['login'], 'deletionCode' => str_random(7)]; $this->events->fire('account.deletion_code.before', array($data)); $wasUpdated = $this->account->update(['id' => $user], ['social_id' => $data['deletionCode']]); if ($wasUpdated) { $this->events->fire('account.deletion_code.after', [$data]); $this->meta->set($user, 'deletion_last', Carbon::now()); $this->accountMailer->deletionCode($data)->send(); } return $wasUpdated; }