How to customize auth controller in laravel 5.3?

501 views Asked by At

I am facing a problem in the auth controller. I have almost made a project in Laravel 5.3. And the database is Clusterpoint. I have made a login function and its working fine. But now I try to implement the auth controller in laravel. It have already its own login and register controller and view. From one of the solution I update the login controller and custom middleware with postSignIn function. As per the solution it will override the auth login function. But when I try to do so it is not working. I am give below the already working code with out auth controller.

public function doLogin(Request $request)
{
    $db_name='test_db';

    $email=$_POST['email'];
    $password=$_POST['password'];
    $email_md5=md5($email);
    $pass_md5=md5($password);
    $cp = new Client();
    $collection = $cp->database($db_name.".users");
    $response = $collection->select('_id, email')->where('_id', '==' ,$email_md5)->where('password', '==', $pass_md5)->get();
    $rawResponse = $response->rawResponse();
    $data_array=json_decode($rawResponse, true);
    $array_all=$data_array['results'];
    //echo '<pre>'; print_r($array_all); die;
    $count=$data_array['hits'];
    if($count==1){
        $value='on';
        Session::set('s_val', $value);
        Session::set('user_id', $email_md5);
        Session::set('user_name', $email);

        return redirect()->action('CampaignController@getIndex');
    } else {
        return redirect()->action('HomeController@showLogin');
    }
}

Please guide me how to do the custom login function like above. Thanks in advance for the help.

0

There are 0 answers