@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php namespace jlourenco\base; |
| 2 | 2 | |
| 3 | -use jlourenco\base\Repositories\SettingsRepositoryInterface; |
|
| 4 | -use jlourenco\base\Repositories\UserRepositoryInterface; |
|
| 5 | -use jlourenco\base\Repositories\LogRepositoryInterface; |
|
| 6 | -use jlourenco\base\Repositories\VisitsRepositoryInterface; |
|
| 7 | -use jlourenco\base\Repositories\JobsRepositoryInterface; |
|
| 8 | -use BadMethodCallException; |
|
| 9 | -use Request; |
|
| 10 | -use Jenssegers\Agent\Agent; |
|
| 11 | -use GeoIP; |
|
| 3 | +use jlourenco\base\Repositories\SettingsRepositoryInterface; |
|
| 4 | +use jlourenco\base\Repositories\UserRepositoryInterface; |
|
| 5 | +use jlourenco\base\Repositories\LogRepositoryInterface; |
|
| 6 | +use jlourenco\base\Repositories\VisitsRepositoryInterface; |
|
| 7 | +use jlourenco\base\Repositories\JobsRepositoryInterface; |
|
| 8 | +use BadMethodCallException; |
|
| 9 | +use Request; |
|
| 10 | +use Jenssegers\Agent\Agent; |
|
| 11 | +use GeoIP; |
|
| 12 | 12 | use Sentinel; |
| 13 | 13 | |
| 14 | 14 | class Base |
@@ -253,7 +253,7 @@ |
||
| 253 | 253 | $platform = $agent->platform(); |
| 254 | 254 | $pversion = $agent->version($platform); |
| 255 | 255 | |
| 256 | - $browserString = $browser . ' version ' . $version . ' | ' . $platform . ' version ' . $pversion; |
|
| 256 | + $browserString = $browser.' version '.$version.' | '.$platform.' version '.$pversion; |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | $visit = $this->getVisitsRepository()->create(['url' => Request::url(), 'ip' => Request::ip(), 'browser' => $browserString]); |
@@ -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 | } |
@@ -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 | {
|
@@ -1,21 +1,19 @@ |
||
| 1 | 1 | <?php namespace jlourenco\base\Controllers; |
| 2 | 2 | |
| 3 | -use App\Http\Controllers\Controller; |
|
| 4 | -use Illuminate\Support\Facades\Request; |
|
| 5 | -use Sentinel; |
|
| 6 | -use View; |
|
| 7 | -use Validator; |
|
| 8 | -use Input; |
|
| 9 | -use Session; |
|
| 10 | -use Redirect; |
|
| 11 | -use Lang; |
|
| 12 | -use URL; |
|
| 13 | -use Activation; |
|
| 3 | +use Illuminate\Support\Facades\Request; |
|
| 4 | +use Sentinel; |
|
| 5 | +use View; |
|
| 6 | +use Validator; |
|
| 7 | +use Input; |
|
| 8 | +use Redirect; |
|
| 9 | +use Lang; |
|
| 10 | +use URL; |
|
| 11 | +use Activation; |
|
| 14 | 12 | use Base; |
| 15 | 13 | use \Cartalyst\Sentinel\Checkpoints\NotActivatedException; |
| 16 | 14 | use \Cartalyst\Sentinel\Checkpoints\ThrottlingException; |
| 17 | -use Reminder; |
|
| 18 | -use Mail; |
|
| 15 | +use Reminder; |
|
| 16 | +use Mail; |
|
| 19 | 17 | use Illuminate\Support\MessageBag; |
| 20 | 18 | |
| 21 | 19 | class AuthController extends controller |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | public function getForgotPasswordConfirm($userId, $passwordResetCode) |
| 95 | 95 | {
|
| 96 | 96 | // Find the user using the password reset code |
| 97 | - if(!$user = Sentinel::findById($userId)) |
|
| 97 | + if (!$user = Sentinel::findById($userId)) |
|
| 98 | 98 | {
|
| 99 | 99 | // Redirect to the forgot password page |
| 100 | 100 | return Redirect::route('forgot-password')->with('error', Lang::get('base.auth.forgot_password_confirm.error'));
|
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Find the user using the password reset code |
| 136 | - if(!$user = Sentinel::findById($userId)) |
|
| 136 | + if (!$user = Sentinel::findById($userId)) |
|
| 137 | 137 | {
|
| 138 | 138 | // Redirect to the forgot password page |
| 139 | 139 | return Redirect::route('login')->with('error', Lang::get('base.auth.activate.error'));
|
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | return back()->withInput()->withErrors($validator); |
| 186 | 186 | } |
| 187 | 187 | try {
|
| 188 | - foreach(Sentinel::createModel()->getLoginNames() as $loginName) |
|
| 188 | + foreach (Sentinel::createModel()->getLoginNames() as $loginName) |
|
| 189 | 189 | {
|
| 190 | 190 | $data = array( |
| 191 | 191 | $loginName => Input::only('email')["email"],
|
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | // Try to log the user in |
| 196 | - if(Sentinel::authenticate($data, Input::get('remember-me', false)))
|
|
| 196 | + if (Sentinel::authenticate($data, Input::get('remember-me', false)))
|
|
| 197 | 197 | {
|
| 198 | 198 | $user = Sentinel::check(); |
| 199 | 199 | $user->update(['ip' => Request::ip()]); |
| 200 | - Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') logged in with IP ' . Request::ip() );
|
|
| 200 | + Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') logged in with IP '.Request::ip());
|
|
| 201 | 201 | |
| 202 | 202 | // Redirect to the dashboard page |
| 203 | 203 | return Redirect::route("home")->with('success', Lang::get('base.auth.signin.success'));
|
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | $this->messageBag->add('email', Lang::get('base.auth.account.not_activated'));
|
| 210 | 210 | } catch (ThrottlingException $e) {
|
| 211 | 211 | $delay = $e->getDelay(); |
| 212 | - $this->messageBag->add('email', Lang::get('base.auth.account.suspended', compact('delay' )));
|
|
| 212 | + $this->messageBag->add('email', Lang::get('base.auth.account.suspended', compact('delay')));
|
|
| 213 | 213 | } |
| 214 | - Base::Log('Login attempt registred for ' . Input::only('email')["email"] . ' from IP ' . Request::ip() );
|
|
| 214 | + Base::Log('Login attempt registred for '.Input::only('email')["email"].' from IP '.Request::ip());
|
|
| 215 | 215 | |
| 216 | 216 | // Ooops.. something went wrong |
| 217 | 217 | return back()->withInput()->withErrors($this->messageBag); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $rules = array(); |
| 246 | 246 | |
| 247 | 247 | // Declare the rules for the form validation |
| 248 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 248 | + foreach (Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 249 | 249 | $rules[$fieldid] = $field['validator']; |
| 250 | 250 | |
| 251 | 251 | $rules['g-recaptcha-response'] = 'required'; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $data = array(); |
| 269 | 269 | |
| 270 | 270 | // Set the data to the user from the User class |
| 271 | - foreach(Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 271 | + foreach (Sentinel::createModel()->getRegisterFields() as $fieldid => $field) |
|
| 272 | 272 | $data[$fieldid] = Input::get($fieldid); |
| 273 | 273 | |
| 274 | 274 | // Set the standard data to the user |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $testing = Sentinel::createModel()->getRegisterFields(); |
| 289 | 289 | $user = Sentinel::findById($user->id); |
| 290 | 290 | |
| 291 | - foreach($data as $fieldid => $field) |
|
| 291 | + foreach ($data as $fieldid => $field) |
|
| 292 | 292 | if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) |
| 293 | 293 | $user[$fieldid] = $field; |
| 294 | 294 | |
@@ -314,18 +314,18 @@ discard block |
||
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | 316 | // Send the activation code through email |
| 317 | - Mail::queue('emails.auth.register-activate', $data, function ($m) use ($user) {
|
|
| 318 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 319 | - $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
|
|
| 317 | + Mail::queue('emails.auth.register-activate', $data, function($m) use ($user) {
|
|
| 318 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 319 | + $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
|
|
| 320 | 320 | }); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // If the administrator needs to activate the account send the user a warning saying that |
| 324 | 324 | if ($adminActivation) |
| 325 | 325 | {
|
| 326 | - Mail::queue('emails.auth.register-admin-activate', ['user' => $user], function ($m) use ($user) {
|
|
| 327 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 328 | - $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
|
|
| 326 | + Mail::queue('emails.auth.register-admin-activate', ['user' => $user], function($m) use ($user) {
|
|
| 327 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 328 | + $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
|
|
| 329 | 329 | }); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -337,22 +337,22 @@ discard block |
||
| 337 | 337 | if (Activation::complete($user, $activation->code)) {
|
| 338 | 338 | Sentinel::login($user, false); |
| 339 | 339 | |
| 340 | - Mail::queue('emails.auth.activated', ['user' => $user], function ($m) use ($user) {
|
|
| 341 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 342 | - $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
|
|
| 340 | + Mail::queue('emails.auth.activated', ['user' => $user], function($m) use ($user) {
|
|
| 341 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 342 | + $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
|
|
| 343 | 343 | }); |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - Base::Log('New account registred for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip() );
|
|
| 347 | + Base::Log('New account registred for '.$user->username.' ('.$user->first_name.' '.$user->last_name.') from IP '.Request::ip());
|
|
| 348 | 348 | |
| 349 | 349 | // Redirect to the home page with success menu |
| 350 | - return Redirect::to("login")->with('success', Lang::get('base.auth.signup.success') . $adminActivation ? Lang::get('base.auth.signup.admin') : $userActivation ? Lang::get('base.auth.signup.self') : Lang::get('base.auth.signup.ready'));
|
|
| 350 | + return Redirect::to("login")->with('success', Lang::get('base.auth.signup.success').$adminActivation ? Lang::get('base.auth.signup.admin') : $userActivation ? Lang::get('base.auth.signup.self') : Lang::get('base.auth.signup.ready'));
|
|
| 351 | 351 | } catch (UserExistsException $e) {
|
| 352 | 352 | $this->messageBag->add('email', Lang::get('base.auth.account.already_exists'));
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - Base::Log('New account registration attempt from IP ' . Request::ip() );
|
|
| 355 | + Base::Log('New account registration attempt from IP '.Request::ip());
|
|
| 356 | 356 | |
| 357 | 357 | // Ooops.. something went wrong |
| 358 | 358 | return Redirect::back()->withInput()->withErrors($this->messageBag); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | // Get the user password recovery code |
| 383 | 383 | $user = Sentinel::findByCredentials(['email' => Input::get('email')]);
|
| 384 | 384 | |
| 385 | - if($user) |
|
| 385 | + if ($user) |
|
| 386 | 386 | {
|
| 387 | 387 | //get reminder for user |
| 388 | 388 | $reminder = Reminder::exists($user) ?: Reminder::create($user); |
@@ -390,14 +390,14 @@ discard block |
||
| 390 | 390 | // Data to be used on the email view |
| 391 | 391 | $data = array( |
| 392 | 392 | 'user' => $user, |
| 393 | - 'forgotPasswordUrl' => URL::route('forgot-password-confirm',[$user->id, $reminder->code]),
|
|
| 393 | + 'forgotPasswordUrl' => URL::route('forgot-password-confirm', [$user->id, $reminder->code]),
|
|
| 394 | 394 | ); |
| 395 | 395 | |
| 396 | - Base::Log('Forgot password request for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip() );
|
|
| 396 | + Base::Log('Forgot password request for '.$user->username.' ('.$user->first_name.' '.$user->last_name.') from IP '.Request::ip());
|
|
| 397 | 397 | |
| 398 | 398 | // Send the activation code through email |
| 399 | - Mail::queue('emails.auth.forgot-password', $data, function ($m) use ($user) {
|
|
| 400 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 399 | + Mail::queue('emails.auth.forgot-password', $data, function($m) use ($user) {
|
|
| 400 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 401 | 401 | $m->subject(Lang::get('base.mails.recovery'));
|
| 402 | 402 | }); |
| 403 | 403 | } |
@@ -427,26 +427,26 @@ discard block |
||
| 427 | 427 | // If validation fails, we'll exit the operation now. |
| 428 | 428 | if ($validator->fails()) {
|
| 429 | 429 | // Ooops.. something went wrong |
| 430 | - return Redirect::route('forgot-password-confirm', compact(['userId','passwordResetCode']))->withInput()->withErrors($validator);
|
|
| 430 | + return Redirect::route('forgot-password-confirm', compact(['userId', 'passwordResetCode']))->withInput()->withErrors($validator);
|
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | // Find the user using the password reset code |
| 434 | 434 | $user = Sentinel::findById($userId); |
| 435 | - if(!$reminder = Reminder::complete($user, $passwordResetCode, Input::get('password')))
|
|
| 435 | + if (!$reminder = Reminder::complete($user, $passwordResetCode, Input::get('password')))
|
|
| 436 | 436 | {
|
| 437 | - Base::Log('Forgot password confirm failed for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip() );
|
|
| 437 | + Base::Log('Forgot password confirm failed for '.$user->username.' ('.$user->first_name.' '.$user->last_name.') from IP '.Request::ip());
|
|
| 438 | 438 | |
| 439 | 439 | // Ooops.. something went wrong |
| 440 | 440 | return Redirect::route('login')->with('error', Lang::get('base.auth.forgot_password_confirm.error'));
|
| 441 | 441 | } else {
|
| 442 | 442 | // Send the activation code through email |
| 443 | - Mail::queue('emails.auth.password-changed', [ 'user' => $user], function ($m) use ($user) {
|
|
| 444 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 443 | + Mail::queue('emails.auth.password-changed', ['user' => $user], function($m) use ($user) {
|
|
| 444 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 445 | 445 | $m->subject(Lang::get('base.mails.password_changed'));
|
| 446 | 446 | }); |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - Base::Log('Forgot password confirmed for ' . $user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') from IP ' . Request::ip() );
|
|
| 449 | + Base::Log('Forgot password confirmed for '.$user->username.' ('.$user->first_name.' '.$user->last_name.') from IP '.Request::ip());
|
|
| 450 | 450 | |
| 451 | 451 | // Password successfully reseted |
| 452 | 452 | return Redirect::route('login')->with('success', Lang::get('base.auth.forgot_password_confirm.success'));
|
@@ -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() |
@@ -1,19 +1,18 @@ |
||
| 1 | 1 | <?php namespace jlourenco\base\Controllers; |
| 2 | 2 | |
| 3 | -use App\Http\Controllers\Controller; |
|
| 4 | -use Validator; |
|
| 5 | -use App\Http\Requests; |
|
| 6 | -use Sentinel; |
|
| 7 | -use View; |
|
| 8 | -use Input; |
|
| 9 | -use File; |
|
| 10 | -use Activation; |
|
| 11 | -use Hash; |
|
| 12 | -use Mail; |
|
| 13 | -use URL; |
|
| 14 | -use Illuminate\Support\Facades\Redirect; |
|
| 15 | -use Base; |
|
| 16 | -use DB; |
|
| 3 | +use App\Http\Controllers\Controller; |
|
| 4 | +use Validator; |
|
| 5 | +use Sentinel; |
|
| 6 | +use View; |
|
| 7 | +use Input; |
|
| 8 | +use File; |
|
| 9 | +use Activation; |
|
| 10 | +use Hash; |
|
| 11 | +use Mail; |
|
| 12 | +use URL; |
|
| 13 | +use Illuminate\Support\Facades\Redirect; |
|
| 14 | +use Base; |
|
| 15 | +use DB; |
|
| 17 | 16 | use Lang; |
| 18 | 17 | |
| 19 | 18 | class UsersController extends Controller |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // Do we want to update the user password? |
| 139 | 139 | if ($password = Input::get('password'))
|
| 140 | 140 | {
|
| 141 | - if (Sentinel::validateCredentials($user, [ 'email' => $email, 'password' => Input::get('old-password')]))
|
|
| 141 | + if (Sentinel::validateCredentials($user, ['email' => $email, 'password' => Input::get('old-password')]))
|
|
| 142 | 142 | {
|
| 143 | 143 | $passwordChanged = true; |
| 144 | 144 | $user->password = Hash::make($password); |
@@ -157,18 +157,18 @@ discard block |
||
| 157 | 157 | if ($file = Input::file('pic')) {
|
| 158 | 158 | $extension = $file->getClientOriginalExtension() ?: 'png'; |
| 159 | 159 | $folderName = '/uploads/users/'; |
| 160 | - $destinationPath = public_path() . $folderName; |
|
| 161 | - $safeName = str_random(10) . '.' . $extension; |
|
| 160 | + $destinationPath = public_path().$folderName; |
|
| 161 | + $safeName = str_random(10).'.'.$extension; |
|
| 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 | //save new file path into db |
| 169 | 169 | $user->pic = $safeName; |
| 170 | 170 | |
| 171 | - Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its profile photo. ');
|
|
| 171 | + Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its profile photo. ');
|
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Was the user updated? |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | if ($passwordChanged) |
| 180 | 180 | {
|
| 181 | - Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its password. ');
|
|
| 182 | - Mail::queue('emails.account.password-changed', [ 'user' => $user ], function ($m) use ($user) {
|
|
| 183 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 181 | + Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its password. ');
|
|
| 182 | + Mail::queue('emails.account.password-changed', ['user' => $user], function($m) use ($user) {
|
|
| 183 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 184 | 184 | $m->subject(Lang::get('base.mails.password_changed'));
|
| 185 | 185 | }); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') updated the profile. ');
|
|
| 188 | + Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') updated the profile. ');
|
|
| 189 | 189 | |
| 190 | 190 | // Redirect to the user page |
| 191 | 191 | return Redirect::route('profile')->with('success', $success);
|
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // Do we want to update the user password? |
| 235 | 235 | $password = Input::get('password');
|
| 236 | 236 | |
| 237 | - if (Sentinel::validateCredentials($user, [ 'email' => $user->email, 'password' => Input::get('old-password')]))
|
|
| 237 | + if (Sentinel::validateCredentials($user, ['email' => $user->email, 'password' => Input::get('old-password')]))
|
|
| 238 | 238 | {
|
| 239 | 239 | $user->password = Hash::make($password); |
| 240 | 240 | $redirect = 'change-password'; |
@@ -251,12 +251,12 @@ discard block |
||
| 251 | 251 | // Prepare the success message |
| 252 | 252 | $success = Lang::get('base.auth.account.changed');
|
| 253 | 253 | |
| 254 | - Mail::queue('emails.account.password-changed', [ 'user' => $user ], function ($m) use ($user) {
|
|
| 255 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 254 | + Mail::queue('emails.account.password-changed', ['user' => $user], function($m) use ($user) {
|
|
| 255 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 256 | 256 | $m->subject(Lang::get('base.mails.password_changed'));
|
| 257 | 257 | }); |
| 258 | 258 | |
| 259 | - Base::Log($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') changed its password account. ');
|
|
| 259 | + Base::Log($user->username.' ('.$user->first_name.' '.$user->last_name.') changed its password account. ');
|
|
| 260 | 260 | |
| 261 | 261 | // Redirect to the user page |
| 262 | 262 | return Redirect::route($redirect)->with('success', $success);
|
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | $activation = Activation::exists($user); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if($activation) |
|
| 356 | + if ($activation) |
|
| 357 | 357 | Activation::complete($user, $activation->code); |
| 358 | 358 | |
| 359 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was accepted. ', $user->id);
|
|
| 359 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was accepted. ', $user->id);
|
|
| 360 | 360 | |
| 361 | - Mail::queue('emails.account.accepted-by-admin', [ 'user' => $user ], function ($m) use ($user) {
|
|
| 362 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 361 | + Mail::queue('emails.account.accepted-by-admin', ['user' => $user], function($m) use ($user) {
|
|
| 362 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 363 | 363 | $m->subject(Lang::get('base.mails.account_accepted'));
|
| 364 | 364 | }); |
| 365 | 365 | |
@@ -399,11 +399,11 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | if ($user->save()) |
| 401 | 401 | {
|
| 402 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was refused. ', $user->id);
|
|
| 402 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was refused. ', $user->id);
|
|
| 403 | 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 | + Mail::queue('emails.account.refused-by-admin', ['user' => $user], function($m) use ($user) {
|
|
| 406 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 407 | 407 | $m->subject(Lang::get('base.mails.account_accepted'));
|
| 408 | 408 | }); |
| 409 | 409 | |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | // Check if we are not trying to delete ourselves |
| 489 | - if ($user->id === Sentinel::getUser()->id) {
|
|
| 489 | + if ($user->id === Sentinel::getUser()->id) {
|
|
| 490 | 490 | // Prepare the error message |
| 491 | 491 | $error = Lang::get('base.base.error');
|
| 492 | 492 | |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | public function getAdminEdit($id = null) |
| 578 | 578 | {
|
| 579 | 579 | // Get the user information |
| 580 | - if($user = Sentinel::findById($id)) |
|
| 580 | + if ($user = Sentinel::findById($id)) |
|
| 581 | 581 | {
|
| 582 | 582 | // Get this user groups |
| 583 | 583 | $userRoles = $user->getRoles()->lists('name', 'id')->all();
|
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | try {
|
| 658 | 658 | // Update the user |
| 659 | - $user->gender = Input::get('gender');
|
|
| 659 | + $user->gender = Input::get('gender');
|
|
| 660 | 660 | $user->first_name = Input::get('first_name');
|
| 661 | 661 | $user->last_name = Input::get('last_name');
|
| 662 | 662 | $user->username = Input::get('username');
|
@@ -689,16 +689,16 @@ discard block |
||
| 689 | 689 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
| 690 | 690 | {
|
| 691 | 691 | $folderName = '/uploads/users/'; |
| 692 | - $destinationPath = public_path() . $folderName; |
|
| 692 | + $destinationPath = public_path().$folderName; |
|
| 693 | 693 | $safeName = str_random(10).'.'.$extension; |
| 694 | 694 | $file->move($destinationPath, $safeName); |
| 695 | 695 | |
| 696 | 696 | //delete old pic if exists |
| 697 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 698 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 697 | + if (File::exists(public_path().$folderName.$user->pic)) |
|
| 698 | + File::delete(public_path().$folderName.$user->pic); |
|
| 699 | 699 | |
| 700 | 700 | //save new file path into db |
| 701 | - $user->pic = $safeName; |
|
| 701 | + $user->pic = $safeName; |
|
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | $status = $activation = Activation::completed($user); |
| 734 | 734 | $currentStatus = Input::get('status');
|
| 735 | 735 | |
| 736 | - if($currentStatus != $status) |
|
| 736 | + if ($currentStatus != $status) |
|
| 737 | 737 | {
|
| 738 | 738 | if ($currentStatus == 0) |
| 739 | 739 | // Remove existing activation record |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | $activation = Activation::exists($user); |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if($activation) |
|
| 752 | + if ($activation) |
|
| 753 | 753 | Activation::complete($user, $activation->code); |
| 754 | 754 | } |
| 755 | 755 | |
@@ -763,16 +763,16 @@ discard block |
||
| 763 | 763 | {
|
| 764 | 764 | if ($password_changed && Input::get('send_new_password_email'))
|
| 765 | 765 | {
|
| 766 | - Mail::queue('emails.account.password-changed-by-admin', [ 'user' => $user, 'new_password' => $password ], function ($m) use ($user) {
|
|
| 767 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 766 | + Mail::queue('emails.account.password-changed-by-admin', ['user' => $user, 'new_password' => $password], function($m) use ($user) {
|
|
| 767 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 768 | 768 | $m->subject(Lang::get('base.mails.password_changed'));
|
| 769 | 769 | }); |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | if ($password_changed) |
| 773 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
|
|
| 773 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') password was changed by an admin. ', $user->id);
|
|
| 774 | 774 | |
| 775 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
|
|
| 775 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') profile was changed by an admin. ', $user->id);
|
|
| 776 | 776 | |
| 777 | 777 | // Prepare the success message |
| 778 | 778 | $success = Lang::get('base.auth.user_changed');
|
@@ -864,36 +864,36 @@ discard block |
||
| 864 | 864 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
| 865 | 865 | {
|
| 866 | 866 | $folderName = '/uploads/users/'; |
| 867 | - $destinationPath = public_path() . $folderName; |
|
| 867 | + $destinationPath = public_path().$folderName; |
|
| 868 | 868 | $safeName = str_random(10).'.'.$extension; |
| 869 | 869 | $file->move($destinationPath, $safeName); |
| 870 | 870 | |
| 871 | 871 | //delete old pic if exists |
| 872 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 873 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 872 | + if (File::exists(public_path().$folderName.$user->pic)) |
|
| 873 | + File::delete(public_path().$folderName.$user->pic); |
|
| 874 | 874 | |
| 875 | 875 | //save new file path into db |
| 876 | - $user->pic = $safeName; |
|
| 876 | + $user->pic = $safeName; |
|
| 877 | 877 | } |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | $user->save(); |
| 881 | 881 | |
| 882 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was created by an admin. ', $user->id);
|
|
| 882 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was created by an admin. ', $user->id);
|
|
| 883 | 883 | |
| 884 | 884 | if (Input::get('send_new_password_email'))
|
| 885 | 885 | {
|
| 886 | 886 | if ($activate) |
| 887 | 887 | {
|
| 888 | - Mail::queue('emails.account.account-created-by-admin', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m) use ($user) {
|
|
| 889 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 888 | + Mail::queue('emails.account.account-created-by-admin', ['user' => $user, 'new_password' => Input::get('password')], function($m) use ($user) {
|
|
| 889 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 890 | 890 | $m->subject(Lang::get('base.mails.account_created'));
|
| 891 | 891 | }); |
| 892 | 892 | } |
| 893 | 893 | else |
| 894 | 894 | {
|
| 895 | - Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
|
|
| 896 | - $m2->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 895 | + Mail::queue('emails.account.account-created-by-admin-inactive', ['user' => $user, 'new_password' => Input::get('password')], function($m2) use ($user) {
|
|
| 896 | + $m2->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 897 | 897 | $m2->subject(Lang::get('base.mails.account_created'));
|
| 898 | 898 | }); |
| 899 | 899 | |
@@ -906,9 +906,9 @@ discard block |
||
| 906 | 906 | ); |
| 907 | 907 | |
| 908 | 908 | // Send the activation code through email |
| 909 | - Mail::queue('emails.auth.register-activate', $data, function ($m) use ($user) {
|
|
| 910 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 911 | - $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
|
|
| 909 | + Mail::queue('emails.auth.register-activate', $data, function($m) use ($user) {
|
|
| 910 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 911 | + $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
|
|
| 912 | 912 | }); |
| 913 | 913 | |
| 914 | 914 | } |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | // Check if we are not trying to delete ourselves |
| 972 | - if ($user->id === Sentinel::getUser()->id + 1) {
|
|
| 972 | + if ($user->id === Sentinel::getUser()->id + 1) {
|
|
| 973 | 973 | // Prepare the error message |
| 974 | 974 | $error = Lang::get('base.base.yourself');
|
| 975 | 975 | |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | // Check if we are not trying to delete ourselves |
| 1013 | - if ($user->id === Sentinel::getUser()->id + 1) {
|
|
| 1013 | + if ($user->id === Sentinel::getUser()->id + 1) {
|
|
| 1014 | 1014 | // Prepare the error message |
| 1015 | 1015 | $error = Lang::get('base.base.yourself');
|
| 1016 | 1016 | |
@@ -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); |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php namespace jlourenco\base\Models; |
| 2 | 2 | |
| 3 | -use Illuminate\Database\Eloquent\SoftDeletes; |
|
| 4 | -use Cartalyst\Sentinel\Users\EloquentUser; |
|
| 5 | -use jlourenco\support\Traits\Creation; |
|
| 3 | +use Illuminate\Database\Eloquent\SoftDeletes; |
|
| 4 | +use Cartalyst\Sentinel\Users\EloquentUser; |
|
| 5 | +use jlourenco\support\Traits\Creation; |
|
| 6 | 6 | use Nicolaslopezj\Searchable\SearchableTrait; |
| 7 | 7 | |
| 8 | 8 | class BaseUser extends EloquentUser |
@@ -179,7 +179,7 @@ |
||
| 179 | 179 | 'BlogPost.contents' => 1, |
| 180 | 180 | ], |
| 181 | 181 | 'joins' => [ |
| 182 | - 'BlogPost' => [ 'User.id', 'BlogPost.author' ], |
|
| 182 | + 'BlogPost' => ['User.id', 'BlogPost.author'], |
|
| 183 | 183 | ], |
| 184 | 184 | ]; |
| 185 | 185 | |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php namespace jlourenco\base\Models; |
| 2 | 2 | |
| 3 | 3 | use Illuminate\Database\Eloquent\Model; |
| 4 | -use jlourenco\base\Repositories\LogRepositoryInterface; |
|
| 5 | -use jlourenco\support\Traits\Creation; |
|
| 6 | 4 | |
| 7 | 5 | class Visits extends Model |
| 8 | 6 | { |
@@ -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 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function update($id, Request $request) |
| 31 | 31 | {
|
| 32 | - $this->validate($request, [ 'value' => 'required' ]); |
|
| 32 | + $this->validate($request, ['value' => 'required']); |
|
| 33 | 33 | |
| 34 | 34 | $move = Base::getSettingsRepository()->findOrFail($id); |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $after = $move->value; |
| 41 | 41 | |
| 42 | - Base::Log('Website settings changed. Changed "' . $move->friendly_name . '" value from "' . $before . '" to "' . $after . '"');
|
|
| 42 | + Base::Log('Website settings changed. Changed "'.$move->friendly_name.'" value from "'.$before.'" to "'.$after.'"');
|
|
| 43 | 43 | |
| 44 | 44 | return redirect('admin/settings');
|
| 45 | 45 | } |
@@ -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 | } |