Ignore:
Timestamp:
10/25/21 21:49:53 (3 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
develop, master
Children:
e756bd9
Parents:
05e57e2
Message:

added 2fa, bug fixes, edited blades

Location:
app/Http/Controllers/Auth
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Auth/ForgotPasswordController.php

    r05e57e2 r1c25bcf  
    33namespace App\Http\Controllers\Auth;
    44
     5use App\Helpers\Alert;
    56use App\Http\Requests\Auth\ForgotPasswordRequest;
    67use App\Models\User;
     
    3334        $user->notify(new ForgotPassword($user));
    3435
    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");
    3637
    3738        return redirect()->route("auth.forgotShow");
  • app/Http/Controllers/Auth/LoginController.php

    r05e57e2 r1c25bcf  
    33namespace App\Http\Controllers\Auth;
    44
     5use App\Helpers\Alert;
    56use App\Http\Requests\Auth\LoginRequest;
    67use App\Models\User;
    78use App\Http\Controllers\Controller;
     9use App\Notifications\VerifyUser;
     10use App\Services\Hashid;
    811use Illuminate\Support\Facades\Hash;
     12use Illuminate\Support\Str;
    913
    1014class LoginController extends Controller
    1115{
    12     protected $redirectTo = '/dashboard';
     16    protected $redirectTo = '/';
    1317
    1418    public function __construct()
     
    2226    }
    2327
    24     public function login(LoginRequest $request)
     28    public function login(LoginRequest $request, Hashid $hashid)
    2529    {
    2630        $user = User::whereUsername($request->username)->first();
    2731
     32        if (is_null($user)) {
     33            Alert::flash("Please check your credentials", "error");
     34            return redirect()->route("auth.login");
     35        }
     36
    2837        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");
    3140        }
    3241
    3342        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");
    3645        }
    3746
    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);
    4948        if ($user->is_forgot_password) {
    5049            $user->is_forgot_password = false;
    5150        }
    5251
    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();
    5456
    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            ]);
    5663    }
    5764
Note: See TracChangeset for help on using the changeset viewer.