Пример #1
0
 /**
  * @param  Request                                   $request
  * @throws GeneralException
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function postEmail(Request $request)
 {
     /**
      * First of all check if the input is a valid email
      */
     $this->validate($request, ['email' => 'required|email']);
     /**
      * Make sure user is confirmed before resetting password.
      */
     $user = User::where('email', $request->get('email'))->first();
     if ($user) {
         if ($user->confirmed == 0) {
             throw new GeneralException('Your account is not confirmed. Please click the confirmation link in your e-mail, or ' . '<a href="' . route('account.confirm.resend', $user->id) . '">click here</a>' . ' to resend the confirmation e-mail.');
         }
     } else {
         throw new GeneralException('There is no user with that e-mail address.');
     }
     $response = Password::sendResetLink($request->only('email'), function (Message $message) {
         $message->subject($this->getEmailSubject());
     });
     switch ($response) {
         case Password::RESET_LINK_SENT:
             return redirect()->back()->with('status', trans($response));
         case Password::INVALID_USER:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }
 public function userDetails(View $view)
 {
     $user = User::where('users.id', auth()->user()->id)->join('user_profiles', 'user_profiles.user_id', '=', 'users.id')->first();
     if ($user) {
         $view->with('user', $user);
     }
 }
Пример #3
0
 /**
  * @param $token
  * @return mixed
  * @throws GeneralException
  */
 public function findByToken($token)
 {
     $user = User::where('confirmation_code', $token)->first();
     if (!$user instanceof User) {
         throw new GeneralException(trans('exceptions.frontend.auth.confirmation.not_found'));
     }
     return $user;
 }
 /**
  * AJAX call to fetch all doctors relation a a specialization
  */
 public function getDoctors(Request $request)
 {
     $spec_id = $request->id;
     $specs = User::where('specialization_id', $spec_id)->where('id', '!=', auth()->user()->id)->get();
     $response = "";
     if (count($specs)) {
         foreach ($specs as $spec) {
             $response .= "<option value='" . $spec['id'] . "'>" . $spec['name'] . "</option>";
         }
         return $response;
     } else {
         return json_encode('error: No Doctor matches your request', 500);
     }
 }
 /**
  * Test the registration form
  * Test it works with confirming email on or off, and that the confirm email notification is sent
  * Note: Captcha is disabled by default in phpunit.xml
  */
 public function testRegistrationForm()
 {
     // Make sure our events are fired
     Event::fake();
     // Create any needed resources
     $faker = Faker\Factory::create();
     $name = $faker->name;
     $email = $faker->safeEmail;
     $password = $faker->password(8);
     // Check if confirmation required is on or off
     if (config('access.users.confirm_email')) {
         Notification::fake();
         $this->visit('/register')->type($name, 'name')->type($email, 'email')->type($password, 'password')->type($password, 'password_confirmation')->press('Register')->see('Your account was successfully created. We have sent you an e-mail to confirm your account.')->see('Login')->seePageIs('/')->seeInDatabase(config('access.users_table'), ['email' => $email, 'name' => $name]);
         // Get the user that was inserted into the database
         $user = User::where('email', $email)->first();
         // Check that the user was sent the confirmation email
         Notification::assertSentTo([$user], UserNeedsConfirmation::class);
     } else {
         $this->visit('/register')->type($name, 'name')->type($email, 'email')->type($password, 'password')->type($password, 'password_confirmation')->press('Register')->see('Dashboard')->seePageIs('/')->seeInDatabase(config('access.users_table'), ['email' => $email, 'name' => $name]);
     }
     Event::assertFired(UserRegistered::class);
 }
 /**
  * @param  $input
  * @param  $user
  * @throws GeneralException
  */
 private function checkUserByEmail($input, $user)
 {
     //Figure out if email is not the same
     if ($user->email != $input['email']) {
         //Check to see if email exists
         if (User::where('email', '=', $input['email'])->first()) {
             throw new GeneralException('That email address belongs to a different user.');
         }
     }
 }
Пример #7
0
 /**
  * @param  $input
  * @param  $user
  * @throws GeneralException
  */
 private function checkUserByEmail($input, $user)
 {
     //Figure out if email is not the same
     if ($user->email != $input['email']) {
         //Check to see if email exists
         if (User::where('email', '=', $input['email'])->first()) {
             throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
         }
     }
 }
Пример #8
0
 /**
  * @param  $token
  * @throws GeneralException
  */
 public function confirmAccount($token)
 {
     $user = User::where('confirmation_code', $token)->first();
     if ($user) {
         if ($user->confirmed == 1) {
             throw new GeneralException('Contul este deja confirmat.');
         }
         if ($user->confirmation_code == $token) {
             $user->confirmed = 1;
             return $user->save();
         }
         throw new GeneralException('Codul de confirmare nu este bun.');
     }
     throw new GeneralException('Acest cod de confirmare nu este in baza de date.');
 }
Пример #9
0
 /**
  * @param $token
  * @throws GeneralException
  */
 public function confirmAccount($token)
 {
     $user = User::where('confirmation_code', $token)->first();
     if ($user) {
         if ($user->confirmed == 1) {
             throw new GeneralException("Your account is already confirmed.");
         }
         if ($user->confirmation_code == $token) {
             $user->confirmed = 1;
             return $user->save();
         }
         throw new GeneralException("Your confirmation code does not match.");
     }
     throw new GeneralException("That confirmation code does not exist.");
 }
 /**
  * @return mixed
  */
 public function edit()
 {
     $user = User::where('users.id', auth()->user()->id)->join('user_profiles', 'user_profiles.user_id', '=', 'users.id')->first();
     return view('frontend.user.profile.edit')->withUser($user);
 }
 /**
  * @return \Illuminate\View\View
  */
 public function profile()
 {
     $user = auth()->user();
     $current_user = User::where('users.id', $user->id)->join('user_profiles', 'user_profiles.user_id', '=', 'users.id')->first();
     $reportCount = Reports::where('user_id', $user->id)->count();
     //        $recommendations = Recommendation::where('user_id', $user->id)->count();
     $data = ['user' => $current_user, 'reportCount' => $reportCount];
     return view('frontend.user.profile', $data);
 }
Пример #12
0
 public static function hasAbonament()
 {
     $user = User::where('id', auth()->user()->id)->with('abonamente')->first();
     $abonamente = $user->abonamente;
     return count($abonamente) > 0;
 }
Пример #13
-23
 public function testCreateUserUnconfirmedForm()
 {
     // Make sure our events are fired
     Event::fake();
     // Make sure our notifications are sent
     Notification::fake();
     // Create any needed resources
     $faker = Faker\Factory::create();
     $name = $faker->name;
     $email = $faker->safeEmail;
     $password = $faker->password(8);
     $this->actingAs($this->admin)->visit('/admin/access/user/create')->type($name, 'name')->type($email, 'email')->type($password, 'password')->type($password, 'password_confirmation')->seeIsChecked('status')->uncheck('confirmed')->check('confirmation_email')->check('assignees_roles[2]')->check('assignees_roles[3]')->press('Create')->seePageIs('/admin/access/user')->see('The user was successfully created.')->seeInDatabase('users', ['name' => $name, 'email' => $email, 'status' => 1, 'confirmed' => 0])->seeInDatabase('role_user', ['user_id' => 4, 'role_id' => 2])->seeInDatabase('role_user', ['user_id' => 4, 'role_id' => 3]);
     // Get the user that was inserted into the database
     $user = User::where('email', $email)->first();
     // Check that the user was sent the confirmation email
     Notification::assertSentTo([$user], UserNeedsConfirmation::class);
     Event::assertFired(UserCreated::class);
 }