@@ -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'));
|
@@ -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) |
@@ -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 | |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // Check if we are not trying to delete ourselves |
| 487 | - if ($user->id === Sentinel::getUser()->id) {
|
|
| 487 | + if ($user->id === Sentinel::getUser()->id) {
|
|
| 488 | 488 | // Prepare the error message |
| 489 | 489 | $error = Lang::get('base.base.error');
|
| 490 | 490 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | public function getAdminEdit($id = null) |
| 576 | 576 | {
|
| 577 | 577 | // Get the user information |
| 578 | - if($user = Sentinel::findById($id)) |
|
| 578 | + if ($user = Sentinel::findById($id)) |
|
| 579 | 579 | {
|
| 580 | 580 | // Get this user groups |
| 581 | 581 | $userRoles = $user->getRoles()->lists('name', 'id')->all();
|
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | try {
|
| 642 | 642 | // Update the user |
| 643 | - $user->gender = Input::get('gender');
|
|
| 643 | + $user->gender = Input::get('gender');
|
|
| 644 | 644 | $user->first_name = Input::get('first_name');
|
| 645 | 645 | $user->last_name = Input::get('last_name');
|
| 646 | 646 | $user->username = Input::get('username');
|
@@ -673,16 +673,16 @@ discard block |
||
| 673 | 673 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
| 674 | 674 | {
|
| 675 | 675 | $folderName = '/uploads/users/'; |
| 676 | - $destinationPath = public_path() . $folderName; |
|
| 676 | + $destinationPath = public_path().$folderName; |
|
| 677 | 677 | $safeName = str_random(10).'.'.$extension; |
| 678 | 678 | $file->move($destinationPath, $safeName); |
| 679 | 679 | |
| 680 | 680 | //delete old pic if exists |
| 681 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 682 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 681 | + if (File::exists(public_path().$folderName.$user->pic)) |
|
| 682 | + File::delete(public_path().$folderName.$user->pic); |
|
| 683 | 683 | |
| 684 | 684 | //save new file path into db |
| 685 | - $user->pic = $safeName; |
|
| 685 | + $user->pic = $safeName; |
|
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | $status = $activation = Activation::completed($user); |
| 718 | 718 | $currentStatus = Input::get('status');
|
| 719 | 719 | |
| 720 | - if($currentStatus != $status) |
|
| 720 | + if ($currentStatus != $status) |
|
| 721 | 721 | {
|
| 722 | 722 | if ($currentStatus == 0) |
| 723 | 723 | // Remove existing activation record |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | $activation = Activation::exists($user); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - if($activation) |
|
| 736 | + if ($activation) |
|
| 737 | 737 | Activation::complete($user, $activation->code); |
| 738 | 738 | } |
| 739 | 739 | |
@@ -747,16 +747,16 @@ discard block |
||
| 747 | 747 | {
|
| 748 | 748 | if ($password_changed && Input::get('send_new_password_email'))
|
| 749 | 749 | {
|
| 750 | - Mail::queue('emails.account.password-changed-by-admin', [ 'user' => $user, 'new_password' => $password ], function ($m) use ($user) {
|
|
| 751 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 750 | + Mail::queue('emails.account.password-changed-by-admin', ['user' => $user, 'new_password' => $password], function($m) use ($user) {
|
|
| 751 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 752 | 752 | $m->subject(Lang::get('base.mails.password_changed'));
|
| 753 | 753 | }); |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | if ($password_changed) |
| 757 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);
|
|
| 757 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') password was changed by an admin. ', $user->id);
|
|
| 758 | 758 | |
| 759 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);
|
|
| 759 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') profile was changed by an admin. ', $user->id);
|
|
| 760 | 760 | |
| 761 | 761 | // Prepare the success message |
| 762 | 762 | $success = Lang::get('base.auth.user_changed');
|
@@ -848,36 +848,36 @@ discard block |
||
| 848 | 848 | if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif') |
| 849 | 849 | {
|
| 850 | 850 | $folderName = '/uploads/users/'; |
| 851 | - $destinationPath = public_path() . $folderName; |
|
| 851 | + $destinationPath = public_path().$folderName; |
|
| 852 | 852 | $safeName = str_random(10).'.'.$extension; |
| 853 | 853 | $file->move($destinationPath, $safeName); |
| 854 | 854 | |
| 855 | 855 | //delete old pic if exists |
| 856 | - if(File::exists(public_path() . $folderName . $user->pic)) |
|
| 857 | - File::delete(public_path() . $folderName . $user->pic); |
|
| 856 | + if (File::exists(public_path().$folderName.$user->pic)) |
|
| 857 | + File::delete(public_path().$folderName.$user->pic); |
|
| 858 | 858 | |
| 859 | 859 | //save new file path into db |
| 860 | - $user->pic = $safeName; |
|
| 860 | + $user->pic = $safeName; |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | $user->save(); |
| 865 | 865 | |
| 866 | - Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') account was created by an admin. ', $user->id);
|
|
| 866 | + Base::TargettedLog($user->username.' ('.$user->first_name.' '.$user->last_name.') account was created by an admin. ', $user->id);
|
|
| 867 | 867 | |
| 868 | 868 | if (Input::get('send_new_password_email'))
|
| 869 | 869 | {
|
| 870 | 870 | if ($activate) |
| 871 | 871 | {
|
| 872 | - Mail::queue('emails.account.account-created-by-admin', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m) use ($user) {
|
|
| 873 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 872 | + Mail::queue('emails.account.account-created-by-admin', ['user' => $user, 'new_password' => Input::get('password')], function($m) use ($user) {
|
|
| 873 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 874 | 874 | $m->subject(Lang::get('base.mails.account_created'));
|
| 875 | 875 | }); |
| 876 | 876 | } |
| 877 | 877 | else |
| 878 | 878 | {
|
| 879 | - Mail::queue('emails.account.account-created-by-admin-inactive', [ 'user' => $user, 'new_password' => Input::get('password') ], function ($m2) use ($user) {
|
|
| 880 | - $m2->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 879 | + Mail::queue('emails.account.account-created-by-admin-inactive', ['user' => $user, 'new_password' => Input::get('password')], function($m2) use ($user) {
|
|
| 880 | + $m2->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 881 | 881 | $m2->subject(Lang::get('base.mails.account_created'));
|
| 882 | 882 | }); |
| 883 | 883 | |
@@ -890,9 +890,9 @@ discard block |
||
| 890 | 890 | ); |
| 891 | 891 | |
| 892 | 892 | // Send the activation code through email |
| 893 | - Mail::queue('emails.auth.register-activate', $data, function ($m) use ($user) {
|
|
| 894 | - $m->to($user->email, $user->first_name . ' ' . $user->last_name); |
|
| 895 | - $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
|
|
| 893 | + Mail::queue('emails.auth.register-activate', $data, function($m) use ($user) {
|
|
| 894 | + $m->to($user->email, $user->first_name.' '.$user->last_name); |
|
| 895 | + $m->subject(Lang::get('base.mails.welcome').' '.$user->first_name);
|
|
| 896 | 896 | }); |
| 897 | 897 | |
| 898 | 898 | } |
@@ -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); |
@@ -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 | } |