/** * @param string $service * @param array $input * @return \App\Models\AuthenticatableBase */ public function getAuthModelId($service, $input) { $columnName = $this->serviceAuthenticationRepository->getAuthModelColumn(); $authInfo = $this->serviceAuthenticationRepository->findByServiceAndId($service, array_get($input, 'service_id')); if (!empty($authInfo)) { return $authInfo->{$columnName}; } $authUser = $this->authenticatableRepository->findByEmail(array_get($input, 'email')); if (!empty($authUser)) { $authInfo = $this->serviceAuthenticationRepository->findByServiceAndAuthModelId($service, $authUser->id); if (!empty($authInfo)) { return null; } } else { $authUser = $this->authenticatableRepository->create($input); } $input[$columnName] = $authUser->id; $this->serviceAuthenticationRepository->create($input); return $authUser->id; }
/** * @return bool */ public function resignation() { $user = $this->getUser(); if (empty($user)) { return false; } $guard = $this->getGuard(); $guard->logout(); \Session::flush(); $this->authenticatableRepository->delete($user); return true; }