generated from fintechbd/package-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LP-3 login with mobile email and login_id function added
- Loading branch information
1 parent
cbe74db
commit 5c85616
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
|
||
namespace Fintech\Auth\Traits; | ||
|
||
|
||
trait GuessAuthFieldTrait | ||
{ | ||
/** | ||
* Return user model auth field from input format | ||
* | ||
* @param $request | ||
* @return array | ||
*/ | ||
private function getAuthFieldFromInput($request) | ||
{ | ||
$authFieldValue = $request->input(config('fintech.auth.auth_field', 'login_id')); | ||
|
||
if (filter_var($authFieldValue, FILTER_VALIDATE_EMAIL)) { | ||
return ['email' => $authFieldValue]; | ||
} elseif (preg_match('/^(\d{7,15})$/', $authFieldValue) > 0) { | ||
return ['mobile' => $authFieldValue]; | ||
} else { | ||
return [config('fintech.auth.auth_field', 'login_id') => $authFieldValue]; | ||
} | ||
} | ||
} |