Changeset 1c25bcf for app/Http/Controllers/Auth
- Timestamp:
- 10/25/21 21:49:53 (3 years ago)
- Branches:
- develop, master
- Children:
- e756bd9
- Parents:
- 05e57e2
- Location:
- app/Http/Controllers/Auth
- Files:
-
- 1 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Auth/ForgotPasswordController.php
r05e57e2 r1c25bcf 3 3 namespace App\Http\Controllers\Auth; 4 4 5 use App\Helpers\Alert; 5 6 use App\Http\Requests\Auth\ForgotPasswordRequest; 6 7 use App\Models\User; … … 33 34 $user->notify(new ForgotPassword($user)); 34 35 35 $request->session()->flash("forgotInfo", "We have sent an email to your inbox.");36 Alert::flash( "We have sent an email to your inbox", "error"); 36 37 37 38 return redirect()->route("auth.forgotShow"); -
app/Http/Controllers/Auth/LoginController.php
r05e57e2 r1c25bcf 3 3 namespace App\Http\Controllers\Auth; 4 4 5 use App\Helpers\Alert; 5 6 use App\Http\Requests\Auth\LoginRequest; 6 7 use App\Models\User; 7 8 use App\Http\Controllers\Controller; 9 use App\Notifications\VerifyUser; 10 use App\Services\Hashid; 8 11 use Illuminate\Support\Facades\Hash; 12 use Illuminate\Support\Str; 9 13 10 14 class LoginController extends Controller 11 15 { 12 protected $redirectTo = '/ dashboard';16 protected $redirectTo = '/'; 13 17 14 18 public function __construct() … … 22 26 } 23 27 24 public function login(LoginRequest $request )28 public function login(LoginRequest $request, Hashid $hashid) 25 29 { 26 30 $user = User::whereUsername($request->username)->first(); 27 31 32 if (is_null($user)) { 33 Alert::flash("Please check your credentials", "error"); 34 return redirect()->route("auth.login"); 35 } 36 28 37 if (!$user->is_active) { 29 $request->session()->flash("isActiveError", "Your account is blocked or its not confirmed yet. Please contact with your system administrator or check your email.");30 return redirect()-> back();38 Alert::flash("Your account is blocked or its not confirmed yet. Please contact with your system administrator or check your email.", "error"); 39 return redirect()->route("auth.login"); 31 40 } 32 41 33 42 if (!Hash::check($request->password, $user->password)) { 34 $request->session()->flash("passwordError", "Your password is incorrect");35 return redirect()-> back()->withInput($request->input());43 Alert::flash("Your password is incorrect", "error"); 44 return redirect()->route("auth.login"); 36 45 } 37 46 38 if (auth()->attempt([ 39 "username" => $request->username, 40 "password" => $request->password, 41 "is_active" => true], $request->remember)) { 42 43 $user->is_online = true; 44 $user->save(); 45 46 return redirect()->intended('/dashboard'); 47 } 48 47 //$user->security_code = rand(10000, 99999); 49 48 if ($user->is_forgot_password) { 50 49 $user->is_forgot_password = false; 51 50 } 52 51 53 $request->session()->flash("loginError", "An error occurred while login. Please try again later."); 52 $user->security_code = 1234; 53 $user->verify_token = Str::uuid(); 54 $user->is_online = true; 55 $user->save(); 54 56 55 return redirect()->back()->withInput($request->input()); 57 $user->notify(new VerifyUser($user)); 58 59 return redirect()->route("verify-login.index", [ 60 "id" => $hashid->encode($user->id), 61 "token" => $user->verify_token 62 ]); 56 63 } 57 64
Note:
See TracChangeset
for help on using the changeset viewer.