A
A
abuamr2019-02-05 13:52:58
Laravel
abuamr, 2019-02-05 13:52:58

How to login via mobile phone?

How to make authorization using a mobile phone do not need SMS?
I want to change authorization from email (since you don't need to enter email when registering) to a mobile phone. google didn't help
much thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2019-02-05
@abuamr


If the phone field is in the useres table and you want to do AUTHENTICATION by phone and password without SMS, then for this you need to add the username() method in the App\Http\Controllers\Auth\LoginController controller , which should return the name of the column in which the phone is stored

public function username()
{
        return 'phone';
}

That is, if we assume that you have not changed anything in this controller before, then it should become like this
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{

    use AuthenticatesUsers;

    protected $redirectTo = '/profile';

    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * Тот самый метод
     */
    public function username()
    {
        return 'phone';
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question