描述:
我现在一直在使用Laravel进行一系列项目.在Laravel中实现用户身份验证很简单.现在,我正在处理的结构有点不同 - 我没有本地database的users表或表.我必须进行API调用以查询我需要的内容.
我试过了
public function postSignIn(){
$username = strtolower(Input::get('username'));
$password_api = VSE::user('password',$username); // abc <-----
$password = Input::get('password'); // abc <-----
if ( $password == $password_api ) {
//Log user in
$auth = Auth::attempt(); // Stuck here <----
}
if ($auth) {
return Redirect::to('/dashboard')->with('success', 'Hi '. $username .' ! You have been successfully logged in.');
}
else {
return Redirect::to('/')->with('error', 'Username/Password Wrong')->withInput(Request::except('password'))->with('username', $username);
}
}
Run Code Online (Sandbox Code Playgroud)
更新
我shell_exec在VSE班上使用一个简单的命令连接到API
public static function …Run Code Online (Sandbox Code Playgroud) 我想知道是否可以扩展内置身份验证以使用外部 API 来对用户进行身份验证?我是 Laravel 新手,所以我很感激你的帮助。我正在为我的客户在 Laravel 5.2 中制作一个自定义应用程序,但我不能直接访问他们的数据库服务器,我只能调用他们的 API 来获取用户的详细信息。
谢谢。
我想扩展Laravel股票身份验证,以在利用现有功能的同时使用OAuth服务器进行用户检索和身份验证。我已经设法将扩展EloquentUserProvider为部分覆盖/扩展Illuminate\Contracts\Auth\UserProvider合同的实现。当前的实现如下所示:
class EloquentOauthServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return HcOAuthProvider;
*/
public function boot()
{
Auth::provider('oauth',function($app){
$model = $app['config']['auth.providers.oauth.model'];
$repository = new OauthUserRepository();
return new EloquentOauthUserProvider($app['hash'], $model, $repository);
});
}
}
Run Code Online (Sandbox Code Playgroud)
在auth.php配置中,我像这样更改了描述符:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'oauth',
],
]
'providers' => [
'oauth' => [
'driver' => 'oauth',
'model' => App\Models\User::class,
],
]
Run Code Online (Sandbox Code Playgroud)
到目前为止,这是可行的,我可以覆盖添加逻辑的方法。但我意识到,我还需要覆盖的一些方法SessionGuard类(login并logout要具体),因为我要保存和检索OAuth的具体使用Laravel会话实现令牌。周围有一些建议,但它们要么不起作用(也许他们在Laravel 5.2之前就起作用了),要么需要重写 …
使用Laravel进行发票应用程序开发.我为settings表中的每个用户存储日期和金额格式.
当用户登录他们的帐户时如何设置Session变量?请提出任何建议.我正在使用Laravel 5.3.