@rizaldywirawan You could read the code for the trait and work out what it does yourself: https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
How AuthenticateUsers Trait from Laravel Built-in Authentication Communicate with User Model?
Hai,
Out of curiosity. Can someone tell me how the login process at built-in authentication works?
What i know, the process will use login() method which is from AuthenticateUsers Trait.
Can someone explain to me, where do they define connection to the User model?
Or if I miss something, can please someone explain it for me?
Thank you.
The model to use is specified in config/auth.php
@rizaldywirawan You could read the code for the trait and work out what it does yourself: https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
Halo @martinbean, thank you for your answer, I try to figure out what happen in that code, I try to understand the registration process too (I open it in vendor folder Illuminate blablabla), I follow the connection between file and method, but i still not understand and can't find where they explicitly define the connection to the User Model. I'm still a newbie programmer. This is really interesting, at least IMO.
The model to use is specified in config/auth.php
Hola too @Snapey, thank you for helping me, is this code what you mean ?
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
I try to find in AuthenticateUsers Trait, and i guess this code responsible for the login function:
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}
But i still don't know how the code can refer to config/auth.php, can you give me more hint?
Thank you before
Hola @Snapey and @martinbean, I'm sorry because sometimes I'm reckless.
Today, I found where they define the connection to the App\Userin registration process.
It's in create() method, i'm such a fool because I'm reckless.
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
I'll try to find how they connect it in AuthenticateUsers Trait.
But for now, i will use what Snapey said, because i will move the User Model location.
Thank you so much for your help, I hope you guys can give me a hint about this.
Just ask what you are trying to achieve
Halo @Snapey,
I'm a new programmer, and sometimes i prefer really want to know what is the process behind the authentication. I really admire Laravel, it's so beautiful, structured.
Then, I want to make my own authentication (but sometimes I'm afraid it wont good like the built-in Authentication). The reason i want to make custom authentication is because I use 2 databases here (1 from the a Windows application we called it DB1, and the other one is MySQL database, DB2). Because I'm a newbie, I don't know where to start to override the Laravel built-in authentication.
So I decide to learn, how the built-in works, then make a simple one.
What i want to achieve here is, before user register their username, the application must check that the username is exist in DB1 and save it to DB2 then the application can register it. If it doesn't then the application should reject it.
If you wonder why don't save it to DB1? Because I can't do that, the windows application have an exclusive access, so the database can't be modified while the application run.
And I realize, how fool I am, I guess that process can be done in the create() method in RegisterController.
What do you think about this?
This is the way I realize my foolishness, someone said this in forum:
@Snapey they install laravel and expect to have your experience in a week.
Thank you for your patience in helping me.
I think you have started out trying to tackle a difficult problem.
Better to use the built in authentication until you really know what you are doing.
To be honest, I would focus on whether I really needed two databases?
Hai @Snapey,
Because DB1 used to record billing (since it's a cyber cafe) from the Windows application, this application rule the entire computers, from what application can be installed, windows authorization and so on. And the owner still want to use this application since it's really good, doens't consume much RAM, and really small size.
But, the negative effect, I can't write to that DB, only read.
So you can store your users un mysql using the default auth() code and then create links to the windows database?
Note:
I forgot to tell you that DB1 is Microsoft Access Database that created by the windows application. I already try to use Linked Table Manager, so it will update database in MySQL, but guess what. It doesn't work, the application knows that the table is linked, and it shows error, and by default, we can't even open the database because it has password. But somehow, i found the way to open it, then the owner told me to use that DB to collect the income and make a report. It's an old application.
Hola @Snapey, nope. I can't touch that DB. My previous plan, I just want to use that DB, but it use a freak encryption for the password field. I can't decrypt it, even that's not MD5, this one is the example:
.214A75F0 that's my password in that database, the decrypt version is Harapan12.
But i don't know what is the encryption.
I will use DB2 to store data about complain, member's profile, event, messaging, make a report based on DB1 data and told the available PC to guest user.
Has this discussion come to light? because I also stuck here.
Please or to participate in this conversation.