Example #1
0
 public function login(Request $request)
 {
     if (!empty($request->input('email'))) {
         $email = $request->input('email');
         $password = $request->input('password');
         $user_node = $this->users->getUser($email);
         // Create the Person model
         $user = new Person();
         $user->setNode($user_node);
         if (!empty($user_node)) {
             // Check password and verification
             if (!$user->verified) {
                 $message_bag = new MessageBag();
                 return redirect()->back()->with('errors', $message_bag->add('email', 'Dit emailadres is nog niet geverifieerd.'));
             } elseif (Hash::check($password, $user->password)) {
                 Auth::login($user);
                 // Register the event to Piwik
                 $this->registerPiwikEvent($user->email, 'Login');
                 return redirect($this->redirectTo);
             } else {
                 $message_bag = new MessageBag();
                 return redirect()->back()->with('errors', $message_bag->add('password', 'Het wachtwoord is incorrect.'));
             }
         } else {
             $message_bag = new MessageBag();
             return redirect()->back()->with('errors', $message_bag->add('email', 'Het emailadres werd niet gevonden.'));
         }
     } else {
         $message_bag = new MessageBag();
         return redirect()->back()->with('errors', $message_bag->add('email', 'Het emailadres werd niet gevonden.'));
     }
 }
 /**
  * Deny a user's registration
  *
  * @param  string $token
  * @return mixed
  */
 public function denyRegistration($token, AppMailer $mailer)
 {
     $user = $this->users->denyUser($token);
     if (!empty($user)) {
         $person = new Person();
         $person->setNode($user);
         // Send an email to the user that his email has been confirmed
         $mailer->sendRegistrationDenial($person);
     }
     return redirect('/persons');
 }
Example #3
0
 private function removeAllUsers()
 {
     $count = 0;
     $userNodes = $this->users->getAll();
     $bar = $this->output->createProgressBar(count($userNodes));
     foreach ($userNodes as $userNode) {
         $person = new Person();
         $person->setNode($userNode);
         $person->delete();
         $bar->advance();
         $count++;
     }
     $this->info("");
     $this->info("Removed {$count} Person nodes.");
 }
Example #4
0
 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array  $credentials
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     $users = $this->person_label->getNodes('email', $user->email);
     if ($users->count() > 0) {
         $user_node = $users[0];
         $person = new Person();
         $person->setNode($user_node);
         return $person;
     }
     return user;
 }
Example #5
0
 /**
  * Administrator can view settings of a certain user
  *
  * @param integer $userId
  * @param Request $request
  *
  * @return
  */
 public function userSettings($userId, Request $request)
 {
     if (empty($request->user()) || !$request->user()->hasRole('administrator')) {
         return redirect('/');
     }
     $user = $this->users->getById($userId);
     if (empty($user)) {
         abort(404);
     }
     // The person to view the profile of
     $person = new Person();
     $person->setNode($user);
     $fullUser = $user->getProperties();
     unset($fullUser['created_at']);
     unset($fullUser['MEDEA_UUID']);
     unset($fullUser['password']);
     unset($fullUser['remember_token']);
     unset($fullUser['token']);
     unset($fullUser['updated_at']);
     unset($fullUser['verified']);
     $fullUser['id'] = $userId;
     return view('pages.settings', ['accessLevels' => $this->getProfileAccessLevels(), 'roles' => $person->getRoles(), 'user' => $fullUser]);
 }
Example #6
0
 /**
  * Display the specified resource.
  *
  * @param ShowFindRequest $request
  *
  * @return \Illuminate\Http\Response
  */
 public function show(ShowFindRequest $request)
 {
     $find = $request->getFind();
     // If the user is not owner of the find and not a researcher, obscure the location to 1km accuracy
     if (empty($user) || !empty($find['person']['identifier']) && $find['person']['identifier'] != $user->id && !in_array('onderzoeker', $user->getRoles())) {
         if (!empty($find['findSpot']['location']['lat'])) {
             $find['findSpot']['location']['lat'] = round($find['findSpot']['location']['lat'] / 2, 2) * 2;
             $find['findSpot']['location']['lng'] = round($find['findSpot']['location']['lng'] / 2, 2) * 2;
         }
     }
     $users = new UserRepository();
     // Check if the user of the find allows their name to be displayed on the find details
     $findUser = $users->getById($find['person']['identifier']);
     $publicUserInfo = [];
     if (!empty($findUser)) {
         $person = new Person();
         $person->setNode($findUser);
         if ($person->showNameOnPublicFinds) {
             $publicUserInfo['name'] = $person->lastName . ' ' . $person->firstName;
         }
         // Should there be a link to the profile page
         if ($person->profileAccessLevel == 4 || !empty($request->user()) && ($request->user()->id == $person->id || $request->user()->hasRole($person->getProfileAllowedRoles()))) {
             $publicUserInfo['id'] = $person->id;
         }
     }
     return view('pages.finds-detail', ['fields' => $this->list_values->getFindTemplate(), 'find' => $find, 'publicUserInfo' => $publicUserInfo]);
 }
Example #7
0
 /**
  * Get all the bare nodes of a findEvent
  *
  * @param integer $limit
  * @param integer $offset
  *
  * @return array
  */
 public function getAllWithRoles()
 {
     $client = $this->getClient();
     $findLabel = $client->makeLabel($this->label);
     $findNodes = $findLabel->getNodes();
     $data = [];
     foreach ($findNodes as $findNode) {
         $person = new Person();
         $person->setNode($findNode);
         $personData = array_only($findNode->getProperties(), ['firstName', 'lastName', 'verified']);
         $personData['id'] = $findNode->getId();
         $personData['personType'] = $person->getRoles();
         $data[] = $personData;
     }
     return $data;
 }
Example #8
0
 /**
  * Reset the given user's password.
  *
  * @param  Node  $user
  * @param  string  $password
  * @return void
  */
 protected function resetPassword($user, $password)
 {
     $person = new Person();
     $person->setNode($user);
     $person->setPassword($password);
     $person->setPasswordResetToken('');
     Auth::guard($this->getGuard())->login($person);
 }