@@ -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 | /** |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | public function getSignin() |
| 48 | 48 | {
|
| 49 | 49 | // Is the user logged in? |
| 50 | - if (Sentinel::check()) |
|
| 51 | - return Redirect::route('home');
|
|
| 50 | + if (Sentinel::check()) { |
|
| 51 | + return Redirect::route('home'); |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | // Show the page |
| 54 | 55 | return View('auth.login');
|
@@ -62,8 +63,9 @@ discard block |
||
| 62 | 63 | public function getSignup() |
| 63 | 64 | {
|
| 64 | 65 | // Is the user logged in? |
| 65 | - if (Sentinel::check()) |
|
| 66 | - return Redirect::route('home');
|
|
| 66 | + if (Sentinel::check()) { |
|
| 67 | + return Redirect::route('home'); |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | // Show the page |
| 69 | 71 | return View('auth.register');
|
@@ -77,8 +79,9 @@ discard block |
||
| 77 | 79 | public function getLostPassword() |
| 78 | 80 | {
|
| 79 | 81 | // Is the user logged in? |
| 80 | - if (Sentinel::check()) |
|
| 81 | - return Redirect::route('home');
|
|
| 82 | + if (Sentinel::check()) { |
|
| 83 | + return Redirect::route('home'); |
|
| 84 | + } |
|
| 82 | 85 | |
| 83 | 86 | // Show the page |
| 84 | 87 | return View('auth.forgot-password');
|
@@ -148,8 +151,7 @@ discard block |
||
| 148 | 151 | // Activation was successful |
| 149 | 152 | // Redirect to the login page |
| 150 | 153 | return Redirect::route('login')->with('success', Lang::get('base.auth.activate.success'));
|
| 151 | - } |
|
| 152 | - else |
|
| 154 | + } else |
|
| 153 | 155 | {
|
| 154 | 156 | // Activation not found or not completed. |
| 155 | 157 | $error = Lang::get('base.auth.activate.error');
|
@@ -173,8 +175,9 @@ discard block |
||
| 173 | 175 | 'password' => 'required|between:3,32', |
| 174 | 176 | ); |
| 175 | 177 | |
| 176 | - if (!$isEmail) |
|
| 177 | - $rules['email'] = 'required'; |
|
| 178 | + if (!$isEmail) { |
|
| 179 | + $rules['email'] = 'required'; |
|
| 180 | + } |
|
| 178 | 181 | |
| 179 | 182 | // Create a new validator instance from our validation rules |
| 180 | 183 | $validator = Validator::make(Input::all(), $rules); |
@@ -239,14 +242,16 @@ discard block |
||
| 239 | 242 | $userActivation = $signupStatus == 2; |
| 240 | 243 | $adminActivation = $signupStatus == 3; |
| 241 | 244 | |
| 242 | - if (!$signupEnabled) |
|
| 243 | - return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled'));
|
|
| 245 | + if (!$signupEnabled) { |
|
| 246 | + return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled')); |
|
| 247 | + } |
|
| 244 | 248 | |
| 245 | 249 | $rules = array(); |
| 246 | 250 | |
| 247 | 251 | // Declare the rules for the form validation |
| 248 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 249 | - $rules[$fieldid] = $field['validator']; |
|
| 252 | + foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) { |
|
| 253 | + $rules[$fieldid] = $field['validator']; |
|
| 254 | + } |
|
| 250 | 255 | |
| 251 | 256 | $rules['g-recaptcha-response'] = 'required'; |
| 252 | 257 | |
@@ -257,8 +262,9 @@ discard block |
||
| 257 | 262 | |
| 258 | 263 | // If validation fails, we'll exit the operation now. |
| 259 | 264 | if ($validator->fails() || ($err = $this->captchaCheck()) == false) {
|
| 260 | - if ($err) |
|
| 261 | - return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]);
|
|
| 265 | + if ($err) { |
|
| 266 | + return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]); |
|
| 267 | + } |
|
| 262 | 268 | |
| 263 | 269 | // Ooops.. something went wrong |
| 264 | 270 | return Redirect::to(URL::previous())->withInput()->withErrors($validator); |
@@ -268,15 +274,17 @@ discard block |
||
| 268 | 274 | $data = array(); |
| 269 | 275 | |
| 270 | 276 | // Set the data to the user from the User class |
| 271 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 272 | - $data[$fieldid] = Input::get($fieldid); |
|
| 277 | + foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) { |
|
| 278 | + $data[$fieldid] = Input::get($fieldid); |
|
| 279 | + } |
|
| 273 | 280 | |
| 274 | 281 | // Set the standard data to the user |
| 275 | 282 | $data['ip'] = Request::getClientIP(); |
| 276 | 283 | $data['status'] = 0; |
| 277 | 284 | $data['staff'] = 0; |
| 278 | - if ($data['birthday'] != null) |
|
| 279 | - $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']);
|
|
| 285 | + if ($data['birthday'] != null) { |
|
| 286 | + $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']); |
|
| 287 | + } |
|
| 280 | 288 | |
| 281 | 289 | // Find the user if it exists and needs to be created |
| 282 | 290 | $user = Sentinel::getUserRepository()->findByCredentials(['email' => Input::get('email')]);
|
@@ -288,19 +296,21 @@ discard block |
||
| 288 | 296 | $testing = Sentinel::createModel()->getRegisterFields(); |
| 289 | 297 | $user = Sentinel::findById($user->id); |
| 290 | 298 | |
| 291 | - foreach($data as $fieldid => $field) |
|
| 292 | - if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) |
|
| 293 | - $user[$fieldid] = $field; |
|
| 299 | + foreach($data as $fieldid => $field) { |
|
| 300 | + if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) |
|
| 301 | + $user[$fieldid] = $field; |
|
| 302 | + } |
|
| 294 | 303 | |
| 295 | 304 | $user['password'] = bcrypt($user['password']); |
| 296 | 305 | Sentinel::update($user, ['email' => Input::get('email')]);
|
| 297 | - } |
|
| 298 | - else |
|
| 299 | - return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed'));
|
|
| 306 | + } else { |
|
| 307 | + return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed')); |
|
| 308 | + } |
|
| 300 | 309 | } |
| 301 | 310 | // Register the user |
| 302 | - else |
|
| 303 | - $user = Sentinel::register($data, false); |
|
| 311 | + else { |
|
| 312 | + $user = Sentinel::register($data, false); |
|
| 313 | + } |
|
| 304 | 314 | |
| 305 | 315 | // If the user needs to activate the account send him an email |
| 306 | 316 | if ($userActivation) |
@@ -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 | |
@@ -582,8 +584,7 @@ discard block |
||
| 582 | 584 | |
| 583 | 585 | // Get a list of all the available groups |
| 584 | 586 | $roles = Sentinel::getRoleRepository()->all(); |
| 585 | - } |
|
| 586 | - else |
|
| 587 | + } else |
|
| 587 | 588 | {
|
| 588 | 589 | // Prepare the error message |
| 589 | 590 | $error = Lang::get('base.auth.not_found');
|
@@ -647,13 +648,15 @@ discard block |
||
| 647 | 648 | $user->email = Input::get('email');
|
| 648 | 649 | $user->description = Input::get('description');
|
| 649 | 650 | |
| 650 | - if (Input::get('force_new_password'))
|
|
| 651 | - $user->force_new_password = 1; |
|
| 652 | - else |
|
| 653 | - $user->force_new_password = 0; |
|
| 651 | + if (Input::get('force_new_password')) { |
|
| 652 | + $user->force_new_password = 1; |
|
| 653 | + } else { |
|
| 654 | + $user->force_new_password = 0; |
|
| 655 | + } |
|
| 654 | 656 | |
| 655 | - if (Input::get('birthday') != null)
|
|
| 656 | - $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));
|
|
| 657 | + if (Input::get('birthday') != null) { |
|
| 658 | + $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday')); |
|
| 659 | + } |
|
| 657 | 660 | |
| 658 | 661 | $password_changed = false; |
| 659 | 662 | |
@@ -678,8 +681,9 @@ discard block |
||
| 678 | 681 | $file->move($destinationPath, $safeName); |
| 679 | 682 | |
| 680 | 683 | //delete old pic if exists |
| 681 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 682 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 684 | + if(File::exists(public_path() . $folderName . $user->pic)) { |
|
| 685 | + File::delete(public_path() . $folderName . $user->pic); |
|
| 686 | + } |
|
| 683 | 687 | |
| 684 | 688 | //save new file path into db |
| 685 | 689 | $user->pic = $safeName; |
@@ -719,10 +723,10 @@ discard block |
||
| 719 | 723 | |
| 720 | 724 | if($currentStatus != $status) |
| 721 | 725 | {
|
| 722 | - if ($currentStatus == 0) |
|
| 723 | - // Remove existing activation record |
|
| 724 | - Activation::remove($user); |
|
| 725 | - else |
|
| 726 | + if ($currentStatus == 0) { |
|
| 727 | + // Remove existing activation record |
|
| 728 | + Activation::remove($user); |
|
| 729 | + } else |
|
| 726 | 730 | {
|
| 727 | 731 | $activation = Activation::exists($user); |
| 728 | 732 | |
@@ -733,14 +737,15 @@ discard block |
||
| 733 | 737 | $activation = Activation::exists($user); |
| 734 | 738 | } |
| 735 | 739 | |
| 736 | - if($activation) |
|
| 737 | - Activation::complete($user, $activation->code); |
|
| 740 | + if($activation) { |
|
| 741 | + Activation::complete($user, $activation->code); |
|
| 742 | + } |
|
| 738 | 743 | } |
| 739 | 744 | |
| 740 | 745 | $user->status = $currentStatus; |
| 741 | - } |
|
| 742 | - else |
|
| 743 | - $user->status = $currentStatus; |
|
| 746 | + } else { |
|
| 747 | + $user->status = $currentStatus; |
|
| 748 | + } |
|
| 744 | 749 | |
| 745 | 750 | // Was the user updated? |
| 746 | 751 | if ($user->save()) |
@@ -753,8 +758,9 @@ discard block |
||
| 753 | 758 | }); |
| 754 | 759 | } |
| 755 | 760 | |
| 756 | - if ($password_changed) |
|
| 757 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
|
|
| 761 | + if ($password_changed) { |
|
| 762 | + Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id); |
|
| 763 | + } |
|
| 758 | 764 | |
| 759 | 765 | Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
|
| 760 | 766 | |
@@ -834,10 +840,11 @@ discard block |
||
| 834 | 840 | $user->password = Hash::make(Input::get('password'));
|
| 835 | 841 | $user->description = Input::get('description');
|
| 836 | 842 | |
| 837 | - if (Input::get('force_new_password'))
|
|
| 838 | - $user->force_new_password = 1; |
|
| 839 | - else |
|
| 840 | - $user->force_new_password = 0; |
|
| 843 | + if (Input::get('force_new_password')) { |
|
| 844 | + $user->force_new_password = 1; |
|
| 845 | + } else { |
|
| 846 | + $user->force_new_password = 0; |
|
| 847 | + } |
|
| 841 | 848 | |
| 842 | 849 | // is new image uploaded? |
| 843 | 850 | if ($file = Input::file('pic'))
|
@@ -853,8 +860,9 @@ discard block |
||
| 853 | 860 | $file->move($destinationPath, $safeName); |
| 854 | 861 | |
| 855 | 862 | //delete old pic if exists |
| 856 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 857 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 863 | + if(File::exists(public_path() . $folderName . $user->pic)) { |
|
| 864 | + File::delete(public_path() . $folderName . $user->pic); |
|
| 865 | + } |
|
| 858 | 866 | |
| 859 | 867 | //save new file path into db |
| 860 | 868 | $user->pic = $safeName; |
@@ -873,8 +881,7 @@ discard block |
||
| 873 | 881 | $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
| 874 | 882 | $m->subject(Lang::get('base.mails.account_created'));
|
| 875 | 883 | }); |
| 876 | - } |
|
| 877 | - else |
|
| 884 | + } else |
|
| 878 | 885 | {
|
| 879 | 886 | Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
|
| 880 | 887 | $m2->to($user->email, $user->first_name . ' ' . $user->last_name); |
@@ -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 | }); |