| @@ -161,7 +161,7 @@ discard block | ||
| 161 | 161 | /** | 
| 162 | 162 | * Account sign in form processing. | 
| 163 | 163 | * | 
| 164 | - * @return Redirect | |
| 164 | + * @return \Illuminate\Http\RedirectResponse | |
| 165 | 165 | */ | 
| 166 | 166 | public function postSignin() | 
| 167 | 167 |      {
 | 
| @@ -361,7 +361,7 @@ discard block | ||
| 361 | 361 | /** | 
| 362 | 362 | * Forgot password form processing page. | 
| 363 | 363 | * | 
| 364 | - * @return Redirect | |
| 364 | + * @return \Illuminate\Http\RedirectResponse | |
| 365 | 365 | */ | 
| 366 | 366 | public function postForgotPassword() | 
| 367 | 367 |      {
 | 
| @@ -411,7 +411,7 @@ discard block | ||
| 411 | 411 | * | 
| 412 | 412 | * @param number $userId | 
| 413 | 413 | * @param string $passwordResetCode | 
| 414 | - * @return Redirect | |
| 414 | + * @return \Illuminate\Http\RedirectResponse | |
| 415 | 415 | */ | 
| 416 | 416 | public function postForgotPasswordConfirm($userId, $passwordResetCode) | 
| 417 | 417 |      {
 | 
| @@ -49,10 +49,11 @@ discard block | ||
| 49 | 49 | // Is the user logged in? | 
| 50 | 50 | if (Sentinel::check()) | 
| 51 | 51 |          {
 | 
| 52 | -            if (Sentinel::inRole('admin'))
 | |
| 53 | -                return Redirect::route('home');
 | |
| 54 | - else | |
| 55 | -                return Redirect::route('user.home');
 | |
| 52 | +            if (Sentinel::inRole('admin')) { | |
| 53 | +                            return Redirect::route('home'); | |
| 54 | +            } else { | |
| 55 | +                            return Redirect::route('user.home'); | |
| 56 | + } | |
| 56 | 57 | } | 
| 57 | 58 | |
| 58 | 59 | // Show the page | 
| @@ -69,10 +70,11 @@ discard block | ||
| 69 | 70 | // Is the user logged in? | 
| 70 | 71 | if (Sentinel::check()) | 
| 71 | 72 |          {
 | 
| 72 | -            if (Sentinel::inRole('admin'))
 | |
| 73 | -                return Redirect::route('home');
 | |
| 74 | - else | |
| 75 | -                return Redirect::route('user.home');
 | |
| 73 | +            if (Sentinel::inRole('admin')) { | |
| 74 | +                            return Redirect::route('home'); | |
| 75 | +            } else { | |
| 76 | +                            return Redirect::route('user.home'); | |
| 77 | + } | |
| 76 | 78 | } | 
| 77 | 79 | |
| 78 | 80 | // Show the page | 
| @@ -89,10 +91,11 @@ discard block | ||
| 89 | 91 | // Is the user logged in? | 
| 90 | 92 | if (Sentinel::check()) | 
| 91 | 93 |          {
 | 
| 92 | -            if (Sentinel::inRole('admin'))
 | |
| 93 | -                return Redirect::route('home');
 | |
| 94 | - else | |
| 95 | -                return Redirect::route('user.home');
 | |
| 94 | +            if (Sentinel::inRole('admin')) { | |
| 95 | +                            return Redirect::route('home'); | |
| 96 | +            } else { | |
| 97 | +                            return Redirect::route('user.home'); | |
| 98 | + } | |
| 96 | 99 | } | 
| 97 | 100 | |
| 98 | 101 | // Show the page | 
| @@ -145,10 +148,11 @@ discard block | ||
| 145 | 148 | // Is user logged in? | 
| 146 | 149 | if (Sentinel::check()) | 
| 147 | 150 |          {
 | 
| 148 | -            if (Sentinel::inRole('admin'))
 | |
| 149 | -                return Redirect::route('home');
 | |
| 150 | - else | |
| 151 | -                return Redirect::route('user.home');
 | |
| 151 | +            if (Sentinel::inRole('admin')) { | |
| 152 | +                            return Redirect::route('home'); | |
| 153 | +            } else { | |
| 154 | +                            return Redirect::route('user.home'); | |
| 155 | + } | |
| 152 | 156 | } | 
| 153 | 157 | |
| 154 | 158 | // Find the user using the password reset code | 
| @@ -167,8 +171,7 @@ discard block | ||
| 167 | 171 | // Activation was successful | 
| 168 | 172 | // Redirect to the login page | 
| 169 | 173 |              return Redirect::route('login')->with('success', Lang::get('base.auth.activate.success'));
 | 
| 170 | - } | |
| 171 | - else | |
| 174 | + } else | |
| 172 | 175 |          {
 | 
| 173 | 176 | // Activation not found or not completed. | 
| 174 | 177 |              $error = Lang::get('base.auth.activate.error');
 | 
| @@ -192,8 +195,9 @@ discard block | ||
| 192 | 195 | 'password' => 'required|between:3,32', | 
| 193 | 196 | ); | 
| 194 | 197 | |
| 195 | - if (!$isEmail) | |
| 196 | - $rules['email'] = 'required'; | |
| 198 | +        if (!$isEmail) { | |
| 199 | + $rules['email'] = 'required'; | |
| 200 | + } | |
| 197 | 201 | |
| 198 | 202 | // Create a new validator instance from our validation rules | 
| 199 | 203 | $validator = Validator::make(Input::all(), $rules); | 
| @@ -258,14 +262,16 @@ discard block | ||
| 258 | 262 | $userActivation = $signupStatus == 2; | 
| 259 | 263 | $adminActivation = $signupStatus == 3; | 
| 260 | 264 | |
| 261 | - if (!$signupEnabled) | |
| 262 | -            return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled'));
 | |
| 265 | +        if (!$signupEnabled) { | |
| 266 | +                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled')); | |
| 267 | + } | |
| 263 | 268 | |
| 264 | 269 | $rules = array(); | 
| 265 | 270 | |
| 266 | 271 | // Declare the rules for the form validation | 
| 267 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) | |
| 268 | - $rules[$fieldid] = $field['validator']; | |
| 272 | +        foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) { | |
| 273 | + $rules[$fieldid] = $field['validator']; | |
| 274 | + } | |
| 269 | 275 | |
| 270 | 276 | $rules['g-recaptcha-response'] = 'required'; | 
| 271 | 277 | |
| @@ -276,8 +282,9 @@ discard block | ||
| 276 | 282 | |
| 277 | 283 | // If validation fails, we'll exit the operation now. | 
| 278 | 284 |          if ($validator->fails() || ($err = $this->captchaCheck()) == false) {
 | 
| 279 | - if ($err) | |
| 280 | -                return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]);
 | |
| 285 | +            if ($err) { | |
| 286 | +                            return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]); | |
| 287 | + } | |
| 281 | 288 | |
| 282 | 289 | // Ooops.. something went wrong | 
| 283 | 290 | return Redirect::to(URL::previous())->withInput()->withErrors($validator); | 
| @@ -287,15 +294,17 @@ discard block | ||
| 287 | 294 | $data = array(); | 
| 288 | 295 | |
| 289 | 296 | // Set the data to the user from the User class | 
| 290 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) | |
| 291 | - $data[$fieldid] = Input::get($fieldid); | |
| 297 | +            foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) { | |
| 298 | + $data[$fieldid] = Input::get($fieldid); | |
| 299 | + } | |
| 292 | 300 | |
| 293 | 301 | // Set the standard data to the user | 
| 294 | 302 | $data['ip'] = Request::getClientIP(); | 
| 295 | 303 | $data['status'] = 0; | 
| 296 | 304 | $data['staff'] = 0; | 
| 297 | - if ($data['birthday'] != null) | |
| 298 | -                $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']);
 | |
| 305 | +            if ($data['birthday'] != null) { | |
| 306 | +                            $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']); | |
| 307 | + } | |
| 299 | 308 | |
| 300 | 309 | // Find the user if it exists and needs to be created | 
| 301 | 310 |              $user = Sentinel::getUserRepository()->findByCredentials(['email' => Input::get('email')]);
 | 
| @@ -307,19 +316,21 @@ discard block | ||
| 307 | 316 | $testing = Sentinel::createModel()->getRegisterFields(); | 
| 308 | 317 | $user = Sentinel::findById($user->id); | 
| 309 | 318 | |
| 310 | - foreach($data as $fieldid => $field) | |
| 311 | - if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) | |
| 312 | - $user[$fieldid] = $field; | |
| 319 | +                    foreach($data as $fieldid => $field) { | |
| 320 | + if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) | |
| 321 | + $user[$fieldid] = $field; | |
| 322 | + } | |
| 313 | 323 | |
| 314 | 324 | $user['password'] = bcrypt($user['password']); | 
| 315 | 325 |                      Sentinel::update($user, ['email' => Input::get('email')]);
 | 
| 316 | - } | |
| 317 | - else | |
| 318 | -                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed'));
 | |
| 326 | +                } else { | |
| 327 | +                                    return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed')); | |
| 328 | + } | |
| 319 | 329 | } | 
| 320 | 330 | // Register the user | 
| 321 | - else | |
| 322 | - $user = Sentinel::register($data, false); | |
| 331 | +            else { | |
| 332 | + $user = Sentinel::register($data, false); | |
| 333 | + } | |
| 323 | 334 | |
| 324 | 335 | // If the user needs to activate the account send him an email | 
| 325 | 336 | if ($userActivation) | 
| @@ -76,7 +76,6 @@ discard block | ||
| 76 | 76 | /** | 
| 77 | 77 | * Display specified user profil. | 
| 78 | 78 | * | 
| 79 | - * @param int $id | |
| 80 | 79 | * @return Response | 
| 81 | 80 | */ | 
| 82 | 81 | public function show(User $user) | 
| @@ -209,7 +208,6 @@ discard block | ||
| 209 | 208 | /** | 
| 210 | 209 | * Change password form processing page. | 
| 211 | 210 | * | 
| 212 | - * @param int $id | |
| 213 | 211 | * @return Redirect | 
| 214 | 212 | */ | 
| 215 | 213 | public function postChangePassword() | 
| @@ -130,8 +130,9 @@ discard block | ||
| 130 | 130 |          $user->gender = Input::get('gender');
 | 
| 131 | 131 |          $user->description = Input::get('description');
 | 
| 132 | 132 | |
| 133 | -        if (Input::get('birthday') != null)
 | |
| 134 | -            $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
 | |
| 133 | +        if (Input::get('birthday') != null) { | |
| 134 | +                    $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday')); | |
| 135 | + } | |
| 135 | 136 | |
| 136 | 137 | $passwordChanged = false; | 
| 137 | 138 | |
| @@ -142,8 +143,7 @@ discard block | ||
| 142 | 143 |              {
 | 
| 143 | 144 | $passwordChanged = true; | 
| 144 | 145 | $user->password = Hash::make($password); | 
| 145 | - } | |
| 146 | - else | |
| 146 | + } else | |
| 147 | 147 |              {
 | 
| 148 | 148 |                  $error = Lang::get('base.auth.wrong_password');
 | 
| 149 | 149 |                  $validator->messages()->add('old-password', Lang::get('base.auth.wrong_password'));
 | 
| @@ -162,8 +162,9 @@ discard block | ||
| 162 | 162 | $file->move($destinationPath, $safeName); | 
| 163 | 163 | |
| 164 | 164 | //delete old pic if exists | 
| 165 | - if (File::exists(public_path() . $folderName . $user->pic)) | |
| 166 | - File::delete(public_path() . $folderName . $user->pic); | |
| 165 | +            if (File::exists(public_path() . $folderName . $user->pic)) { | |
| 166 | + File::delete(public_path() . $folderName . $user->pic); | |
| 167 | + } | |
| 167 | 168 | |
| 168 | 169 | //save new file path into db | 
| 169 | 170 | $user->pic = $safeName; | 
| @@ -261,8 +262,7 @@ discard block | ||
| 261 | 262 | // Redirect to the user page | 
| 262 | 263 |                      return Redirect::route($redirect)->with('success', $success);
 | 
| 263 | 264 | } | 
| 264 | - } | |
| 265 | - else | |
| 265 | + } else | |
| 266 | 266 |              {
 | 
| 267 | 267 |                  $error = Lang::get('base.auth.wrong_password');
 | 
| 268 | 268 |                  $validator->messages()->add('old-password', Lang::get('base.auth.wrong_password'));
 | 
| @@ -353,8 +353,9 @@ discard block | ||
| 353 | 353 | $activation = Activation::exists($user); | 
| 354 | 354 | } | 
| 355 | 355 | |
| 356 | - if($activation) | |
| 357 | - Activation::complete($user, $activation->code); | |
| 356 | +            if($activation) { | |
| 357 | + Activation::complete($user, $activation->code); | |
| 358 | + } | |
| 358 | 359 | |
| 359 | 360 |              Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was accepted. ', $user->id);
 | 
| 360 | 361 | |
| @@ -401,9 +402,10 @@ discard block | ||
| 401 | 402 |          {
 | 
| 402 | 403 |              Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was refused. ', $user->id);
 | 
| 403 | 404 | |
| 404 | -            if (Base::getSetting('SEND_EMAIL_ON_REFUSE'))
 | |
| 405 | -                Mail::queue('emails.account.refused-by-admin', [ 'user' => $user ], function ($m) use ($user) {
 | |
| 406 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); | |
| 405 | +            if (Base::getSetting('SEND_EMAIL_ON_REFUSE')) { | |
| 406 | +                            Mail::queue('emails.account.refused-by-admin', [ 'user' => $user ], function ($m) use ($user) {
 | |
| 407 | + $m->to($user->email, $user->first_name . ' ' . $user->last_name); | |
| 408 | + } | |
| 407 | 409 |                      $m->subject(Lang::get('base.mails.account_accepted'));
 | 
| 408 | 410 | }); | 
| 409 | 411 | |
| @@ -584,8 +586,7 @@ discard block | ||
| 584 | 586 | |
| 585 | 587 | // Get a list of all the available groups | 
| 586 | 588 | $roles = Sentinel::getRoleRepository()->all(); | 
| 587 | - } | |
| 588 | - else | |
| 589 | + } else | |
| 589 | 590 |          {
 | 
| 590 | 591 | // Prepare the error message | 
| 591 | 592 |              $error = Lang::get('base.auth.not_found');
 | 
| @@ -604,12 +605,14 @@ discard block | ||
| 604 | 605 | foreach ($groups2 as $g) | 
| 605 | 606 |          {
 | 
| 606 | 607 | $has = false; | 
| 607 | - foreach ($user->roles as $g2) | |
| 608 | - if ($g2->id == $g->id) | |
| 609 | - $has = true; | |
| 610 | - | |
| 611 | - if (!$has) | |
| 612 | - $groups[$g->id] = $g->name; | |
| 608 | +            foreach ($user->roles as $g2) { | |
| 609 | + if ($g2->id == $g->id) | |
| 610 | + $has = true; | |
| 611 | + } | |
| 612 | + | |
| 613 | +            if (!$has) { | |
| 614 | + $groups[$g->id] = $g->name; | |
| 615 | + } | |
| 613 | 616 | } | 
| 614 | 617 | |
| 615 | 618 | // Show the page | 
| @@ -663,13 +666,15 @@ discard block | ||
| 663 | 666 |              $user->email       = Input::get('email');
 | 
| 664 | 667 |              $user->description = Input::get('description');
 | 
| 665 | 668 | |
| 666 | -            if (Input::get('force_new_password'))
 | |
| 667 | - $user->force_new_password = 1; | |
| 668 | - else | |
| 669 | - $user->force_new_password = 0; | |
| 669 | +            if (Input::get('force_new_password')) { | |
| 670 | + $user->force_new_password = 1; | |
| 671 | +            } else { | |
| 672 | + $user->force_new_password = 0; | |
| 673 | + } | |
| 670 | 674 | |
| 671 | -            if (Input::get('birthday') != null)
 | |
| 672 | -                $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
 | |
| 675 | +            if (Input::get('birthday') != null) { | |
| 676 | +                            $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday')); | |
| 677 | + } | |
| 673 | 678 | |
| 674 | 679 | $password_changed = false; | 
| 675 | 680 | |
| @@ -694,8 +699,9 @@ discard block | ||
| 694 | 699 | $file->move($destinationPath, $safeName); | 
| 695 | 700 | |
| 696 | 701 | //delete old pic if exists | 
| 697 | - if(File::exists(public_path() . $folderName . $user->pic)) | |
| 698 | - File::delete(public_path() . $folderName . $user->pic); | |
| 702 | +                    if(File::exists(public_path() . $folderName . $user->pic)) { | |
| 703 | + File::delete(public_path() . $folderName . $user->pic); | |
| 704 | + } | |
| 699 | 705 | |
| 700 | 706 | //save new file path into db | 
| 701 | 707 | $user->pic = $safeName; | 
| @@ -735,10 +741,10 @@ discard block | ||
| 735 | 741 | |
| 736 | 742 | if($currentStatus != $status) | 
| 737 | 743 |              {
 | 
| 738 | - if ($currentStatus == 0) | |
| 739 | - // Remove existing activation record | |
| 740 | - Activation::remove($user); | |
| 741 | - else | |
| 744 | +                if ($currentStatus == 0) { | |
| 745 | + // Remove existing activation record | |
| 746 | + Activation::remove($user); | |
| 747 | + } else | |
| 742 | 748 |                  {
 | 
| 743 | 749 | $activation = Activation::exists($user); | 
| 744 | 750 | |
| @@ -749,14 +755,15 @@ discard block | ||
| 749 | 755 | $activation = Activation::exists($user); | 
| 750 | 756 | } | 
| 751 | 757 | |
| 752 | - if($activation) | |
| 753 | - Activation::complete($user, $activation->code); | |
| 758 | +                    if($activation) { | |
| 759 | + Activation::complete($user, $activation->code); | |
| 760 | + } | |
| 754 | 761 | } | 
| 755 | 762 | |
| 756 | 763 | $user->status = $currentStatus; | 
| 757 | - } | |
| 758 | - else | |
| 759 | - $user->status = $currentStatus; | |
| 764 | +            } else { | |
| 765 | + $user->status = $currentStatus; | |
| 766 | + } | |
| 760 | 767 | |
| 761 | 768 | // Was the user updated? | 
| 762 | 769 | if ($user->save()) | 
| @@ -769,8 +776,9 @@ discard block | ||
| 769 | 776 | }); | 
| 770 | 777 | } | 
| 771 | 778 | |
| 772 | - if ($password_changed) | |
| 773 | -                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
 | |
| 779 | +                if ($password_changed) { | |
| 780 | +                                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id); | |
| 781 | + } | |
| 774 | 782 | |
| 775 | 783 |                  Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
 | 
| 776 | 784 | |
| @@ -850,10 +858,11 @@ discard block | ||
| 850 | 858 |              $user->password = Hash::make(Input::get('password'));
 | 
| 851 | 859 |              $user->description = Input::get('description');
 | 
| 852 | 860 | |
| 853 | -            if (Input::get('force_new_password'))
 | |
| 854 | - $user->force_new_password = 1; | |
| 855 | - else | |
| 856 | - $user->force_new_password = 0; | |
| 861 | +            if (Input::get('force_new_password')) { | |
| 862 | + $user->force_new_password = 1; | |
| 863 | +            } else { | |
| 864 | + $user->force_new_password = 0; | |
| 865 | + } | |
| 857 | 866 | |
| 858 | 867 | // is new image uploaded? | 
| 859 | 868 |              if ($file = Input::file('pic'))
 | 
| @@ -869,8 +878,9 @@ discard block | ||
| 869 | 878 | $file->move($destinationPath, $safeName); | 
| 870 | 879 | |
| 871 | 880 | //delete old pic if exists | 
| 872 | - if(File::exists(public_path() . $folderName . $user->pic)) | |
| 873 | - File::delete(public_path() . $folderName . $user->pic); | |
| 881 | +                    if(File::exists(public_path() . $folderName . $user->pic)) { | |
| 882 | + File::delete(public_path() . $folderName . $user->pic); | |
| 883 | + } | |
| 874 | 884 | |
| 875 | 885 | //save new file path into db | 
| 876 | 886 | $user->pic = $safeName; | 
| @@ -889,8 +899,7 @@ discard block | ||
| 889 | 899 | $m->to($user->email, $user->first_name . ' ' . $user->last_name); | 
| 890 | 900 |                          $m->subject(Lang::get('base.mails.account_created'));
 | 
| 891 | 901 | }); | 
| 892 | - } | |
| 893 | - else | |
| 902 | + } else | |
| 894 | 903 |                  {
 | 
| 895 | 904 |                      Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
 | 
| 896 | 905 | $m2->to($user->email, $user->first_name . ' ' . $user->last_name); | 
| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | */ | 
| 21 | 21 | public function __construct($model = null) | 
| 22 | 22 |      { | 
| 23 | - if (isset($model)) | |
| 24 | - $this->model = $model; | |
| 23 | +        if (isset($model)) { | |
| 24 | + $this->model = $model; | |
| 25 | + } | |
| 25 | 26 | } | 
| 26 | 27 | |
| 27 | 28 | /** | 
| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | */ | 
| 21 | 21 | public function __construct($model = null) | 
| 22 | 22 |      {
 | 
| 23 | - if (isset($model)) | |
| 24 | - $this->model = $model; | |
| 23 | +        if (isset($model)) { | |
| 24 | + $this->model = $model; | |
| 25 | + } | |
| 25 | 26 | } | 
| 26 | 27 | |
| 27 | 28 | /** | 
| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | */ | 
| 18 | 18 | public function handle($request, Closure $next) | 
| 19 | 19 |      { | 
| 20 | -        if (config('jlourenco.base.VisitCounter')) | |
| 21 | - Base::RegisterVisit(); | |
| 20 | +        if (config('jlourenco.base.VisitCounter')) { | |
| 21 | + Base::RegisterVisit(); | |
| 22 | + } | |
| 22 | 23 | |
| 23 | 24 | return $next($request); | 
| 24 | 25 | } | 
| @@ -20,10 +20,11 @@ | ||
| 20 | 20 |          { | 
| 21 | 21 | if ($user->force_new_password) | 
| 22 | 22 |              { | 
| 23 | - if ($request->ajax()) | |
| 24 | -                    return response('New password is required. Login into the website.', 401); | |
| 25 | - else | |
| 26 | -                    return Redirect::route('change-password'); | |
| 23 | +                if ($request->ajax()) { | |
| 24 | +                                    return response('New password is required. Login into the website.', 401); | |
| 25 | +                } else { | |
| 26 | +                                    return Redirect::route('change-password'); | |
| 27 | + } | |
| 27 | 28 | } | 
| 28 | 29 | } | 
| 29 | 30 | return $next($request); | 
| @@ -35,10 +35,11 @@ discard block | ||
| 35 | 35 | */ | 
| 36 | 36 | public function getCreatedByAttribute($value) | 
| 37 | 37 |      { | 
| 38 | - if ($value > 0) | |
| 39 | - if ($user = Sentinel::findUserById($value)) | |
| 38 | +        if ($value > 0) { | |
| 39 | + if ($user = Sentinel::findUserById($value)) | |
| 40 | 40 | if ($user != null) | 
| 41 | 41 | return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')'; | 
| 42 | + } | |
| 42 | 43 | |
| 43 | 44 | return $value; | 
| 44 | 45 | } | 
| @@ -51,10 +52,11 @@ discard block | ||
| 51 | 52 | */ | 
| 52 | 53 | public function getTargetAttribute($value) | 
| 53 | 54 |      { | 
| 54 | - if ($value > 0) | |
| 55 | - if ($user = Sentinel::findUserById($value)) | |
| 55 | +        if ($value > 0) { | |
| 56 | + if ($user = Sentinel::findUserById($value)) | |
| 56 | 57 | if ($user != null) | 
| 57 | 58 | return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')'; | 
| 59 | + } | |
| 58 | 60 | |
| 59 | 61 | return $value; | 
| 60 | 62 | } | 
| @@ -226,9 +226,10 @@ | ||
| 226 | 226 |      {
 | 
| 227 | 227 | $target = null; | 
| 228 | 228 | |
| 229 | - if ($user = Sentinel::getUser()) | |
| 230 | - if ($user != null) | |
| 231 | - $target = $user->id; | |
| 229 | +        if ($user = Sentinel::getUser()) { | |
| 230 | + if ($user != null) | |
| 231 | + $target = $user->id; | |
| 232 | + } | |
| 232 | 233 | |
| 233 | 234 | $log = $this->getLogsRepository()->create(['log' => $logMessage, 'ip' => Request::ip(), 'target' => $target]); | 
| 234 | 235 | } | 
| @@ -71,8 +71,9 @@ discard block | ||
| 71 | 71 | ], 'routes'); | 
| 72 | 72 | |
| 73 | 73 | // Include the routes file | 
| 74 | -        if(file_exists(base_path("app/Http/base_routes.php"))) | |
| 75 | -            include base_path("app/Http/base_routes.php"); | |
| 74 | +        if(file_exists(base_path("app/Http/base_routes.php"))) { | |
| 75 | +                    include base_path("app/Http/base_routes.php"); | |
| 76 | + } | |
| 76 | 77 | } | 
| 77 | 78 | |
| 78 | 79 | /** | 
| @@ -88,8 +89,9 @@ discard block | ||
| 88 | 89 | $users = array_get($config, 'models.User'); | 
| 89 | 90 | $model = array_get($config, 'models.Group'); | 
| 90 | 91 | |
| 91 | - if (class_exists($model) && method_exists($model, 'setUsersModel')) | |
| 92 | - forward_static_call_array([$model, 'setUsersModel'], [$users]); | |
| 92 | +            if (class_exists($model) && method_exists($model, 'setUsersModel')) { | |
| 93 | + forward_static_call_array([$model, 'setUsersModel'], [$users]); | |
| 94 | + } | |
| 93 | 95 | |
| 94 | 96 | return new UserRepository($users); | 
| 95 | 97 | }); |