mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Allow aliases to be entered in the authentication
Fix the authentication password check to allow "alias-accounts"
This commit is contained in:
parent
9cf86e1b6a
commit
c8aa86d77a
1 changed files with 11 additions and 2 deletions
|
|
@ -44,13 +44,22 @@ class AuthenticateController extends Controller
|
|||
public function authenticate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'username' => 'required|exists:external.accounts,username',
|
||||
'username' => 'required',
|
||||
'password' => 'required'
|
||||
]);
|
||||
|
||||
$account = Account::where('username', $request->get('username'))
|
||||
->first();
|
||||
|
||||
// Try alias
|
||||
if (!$account) {
|
||||
$alias = Alias::where('alias', $request->get('username'))->first();
|
||||
|
||||
if ($alias) {
|
||||
$account = $alias->account;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$account) {
|
||||
return redirect()->back()->withErrors(['authentication' => 'The account doesn\'t exists']);
|
||||
}
|
||||
|
|
@ -59,7 +68,7 @@ class AuthenticateController extends Controller
|
|||
foreach ($account->passwords as $password) {
|
||||
if (hash_equals(
|
||||
$password->password,
|
||||
Utils::bchash($request->get('username'), $account->resolvedRealm, $request->get('password'), $password->algorithm)
|
||||
Utils::bchash($account->username, $account->resolvedRealm, $request->get('password'), $password->algorithm)
|
||||
)) {
|
||||
Auth::login($account);
|
||||
return redirect()->route('account.panel');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue