예제 #1
0
 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($provider, $hasCode, AuthenticateUserListener $listener)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst($provider);
     }
     $user = $this->users->findOrCreate($this->getUser($provider));
     if ($user === null) {
         return $this->getAuthorizationFirst($provider);
     }
     $this->auth->login($user, true);
     return $listener->userHasLoggedIn($user);
 }
예제 #2
0
 /**
  * @param boolean $hasCode
  * @param AuthenticateUserListener $listener
  * @param $type
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($hasCode, AuthenticateUserListener $listener, $type)
 {
     if (!$hasCode) {
         return $this->getAuthorizationFirst();
     }
     $linkedInData = $this->getLinkedinUser();
     $user = $this->users->findOrCreate($linkedInData, $type);
     $this->auth->login($user, true);
     $user->authType = 'linkedin';
     $user->save();
     if (is_null($user->profile)) {
         $name = explode(' ', $linkedInData->name);
         $profile = new Profile(['first_name' => head($name), 'last_name' => last($name)]);
         $user->profile()->save($profile);
     }
     return $listener->userHasLoggedIn($user);
 }
 public function addAdvertisementInvite(AdvertisementRequest $request, User $user, Company $company, Advertisement $advertisement, Picture $picture)
 {
     $this->valid_image($request->images);
     $images = ImageManagement::upload_image($request->file('images'));
     $newUser = $user->findOrCreate($request);
     if ($request->user_type) {
         $newCompany = $company->create($request, $newUser->id);
         $newUser = $newCompany->company()->associate($newUser);
     }
     $newAdvertisement = $advertisement->create($request);
     $newAdvertisement->user()->associate($newUser);
     $newAdvertisement = $advertisement->associateIdType($request['ads_type'], $newAdvertisement);
     $newAdvertisement = $advertisement->associateIdCategory($request['category'], $newAdvertisement);
     $newAdvertisement = $advertisement->associateIdCity($request['id_city'], $newAdvertisement);
     foreach ($images as $value) {
         $newAdvertisement->picture[] = $picture->create($value);
     }
     Session::put('advertisement', $newAdvertisement);
     return Redirect::route('advertisement.invite.validation');
 }