“门面设计模式”中有超过1个门面类?(More than 1 facade class in 'facade design pattern'?)
在立面设计模式中制作多于1个外观类 (非实例)是否可以接受? 我的意思是,它是否被正式禁止? 它会抑制“立面设计模式”的优势吗?
Is it acceptable to make more than 1 facade class (not instance) in a facade design pattern? I mean, is it formally forbidden ? Will it inhibit the 'facade design pattern' advantage itself?
原文:https://stackoverflow.com/questions/301509
最满意答案
contain
选项在CakePHP 3.1之前,使用contains选项
$this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'contain' => ['UsersProfiles'] ] ] ]);
定制查找器
从3.1开始,您可以使用
finder
选项定义用于构建获取用户数据的查询的finder$this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'finder' => 'auth' ] ] ]);
在你的表类中
public function findAuth(\Cake\ORM\Query $query, array $options) { return $query->contain(['UsersProfiles']); }
两种解决方案
将确保
AuthComponent::identify()
返回的数据将包含关联的UsersProfiles
。也可以看看
The
contain
optionBefore CakePHP 3.1, use the
contain
option$this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'contain' => ['UsersProfiles'] ] ] ]);
A custom finder
As of 3.1 you can use the
finder
option to define the finder to use for building the query that fetches the user data$this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'finder' => 'auth' ] ] ]);
In your table class
public function findAuth(\Cake\ORM\Query $query, array $options) { return $query->contain(['UsersProfiles']); }
Both solutions
will ensure that the data returned by
AuthComponent::identify()
will contain the associatedUsersProfiles
.See also
相关问答
更多-
发生这种情况是因为没有安装pycrypto库。 它需要在app.xml中安装和引用。 请参阅android中的云端点身份验证:Oauth框架用户与oauth令牌用户不匹配 This was happening because they pycrypto library was not installed. It needs to be installed and referenced in app.xml. See Cloud endpoints authentication from android: O ...
-
如何使用Ember简单身份验证获取当前经过身份验证的用户?(How do I get the currently authenticated user with Ember simple auth?)[2022-04-29]
我能够使用 this.get('session.user_email') 在我的应用程序路由中找到经过身份验证的用户。 更好的方法是重新打开session对象并添加引用经过身份验证的用户的属性。 请参阅指南中的此示例 。 I was able to use this.get('session.user_email') in my application route to find the authenticated user. The better way to do it is to reopen t ... -
如何检索数据,以便仅提取用户保存的内容? 如何使数据库仅检查当前用户保存的数据,然后允许对其进行检索。 这些是略有不同的问题,但似乎问同样的事情。 假设你的问题,结构如下 firebase_key_0 user_id: uid_0 month: 06 number: 42 firebase_key_1 user_id: uid_1 month: 03 number: .14 然后是一个基本的firebase查询来获取特定数据; 这是获取用户uid_1号码的代 ...
-
如果经过身份验证的Express / Node JS,则将用户数据放入所有路由(putting User data in all routes if authenticated Express/Node JS)[2022-05-25]
查看Express文档中的res.locals 。 这可能对你有用。 http://expressjs.com/en/api.html#res.locals 另外,请参阅此答案以帮助了解res.locals的工作原理。 app.use(function(req, res, next){ res.locals.user = session.user; next(); }); 前端(玉模板,但你可以使用你想要的任何模板引擎) extends layout block content ... -
干得好。 我不确定你确实要存储多少数据,但是......有一个iOS包装器可以在一个名为NSUserDefaults的plist中本地存储少量数据。 它真的很容易使用。 查看文档 它使用KVC来设置/获取数据。 下面是一个简单的例子: 保存数据 [[NSUserDefaults standardUserDefaults] setString:myString forKey:@"username"]; [[NSUserDefaults standardUserDefaults] synchronize]; ...
-
当您在没有任何$user对象时创建新用户时,您肯定会得到一个Undefined variable: user错误消息。 您的验证仅适用于更新用户个人资料。 您的代码中存在语法错误。 这是正确的: return Validator::make($data, [ 'name' => 'required|regex:/^[a-zA-Z]+$/u|max:255|unique:users,name', 'email' => 'required|email|max:255|uniqu ...
-
这是我在这里给出的iOS答案的更多端口 Firebase为使用FIRAuth Clases / API的用户提供身份验证 但是,他们无法使用Firebase数据库等自定义字段进行编辑。 要允许用户使用自定义字段,您需要使用您在用户的身份验证中收到的同一唯一uid来复制数据库中的用户。 像这样的东西 FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user != null) { // User is signed i ...
-
只是挖掘源代码,我找到了Github - Google_Service_Oauth2.php $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me')); $google_oauthV2 = Google_Service_Oauth2($client); dump($google_oauthV2->userinf ...
-
如何与经过身份验证的用户数据一起检索关联?(How to retrieve associations together with authenticated user data?)[2021-07-05]
contain选项 在CakePHP 3.1之前,使用contains选项 $this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'contain' => ['UsersProfiles'] ] ] ]); 定制查找器 从3.1开始,您可以使用finder选项定义用于构建获取用户数据的查询的finder $this->loadComponent('Auth', [ ... -
你需要将fbClient.GetAsync中的outpout放入变量中,例如 JsonResult result = fbClient.GetAsync( "/me", new Dictionary
{ {"fields", "id, name, first_name, last_name, picture"}, {"access_token", App._accessToken} }); 然后从结果 ...