Support the ongoing development of Laravel.io →
Configuration Eloquent Architecture
Last updated 2 years ago.
0

I would have everyone login with email address and have a field that denotes their role (staff.student, etc)

However, if you have to use username or email, I would check if the entered username contains a "@" if it does authenticate using email and password otherwise username and password

if(strpos($username, '@') === false )
{
    if (Auth::attempt(['username' => $username, 'password' => $password]))
    {
        // A student authenticated
    }
}else{
    if (Auth::attempt(['email' => $username, 'password' => $password]))
    {
        // Someone else authenticated
    }
}

untested,,,

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.