目前我正在使用 Laravel 构建 Rest API。对于身份验证,我使用 Sanctum 包。每次用户登录时,它都会生成一个如下所示的令牌:
"token": "98|b45h97e17VVpugjO71wwURoicIqDQP2ejTkCWwoD"
Run Code Online (Sandbox Code Playgroud)
但为什么 Sanctum 将数据库 ID 包含在令牌中呢?
如何从令牌中删除数据库 ID?
我正在尝试添加autocomplete=new-password
到一些用户编辑表单中,但它未能遵循 Chrome 79 和 Firefox 71 中的正确行为。这两种浏览器都应该支持它。
这里有什么问题?
我创建了两个非常简单的示例来消除对问题的任何外部干扰。它们可以从任何 HTTP 服务器(例如php -S localhost:8999
)提供服务。第一个页面触发“保存登录”功能,但第二个页面不应该使用该信息来自动完成密码 - 然而,它确实如此。
<!-- login.htm -->
<html>
<head></head>
<body>
<form action="edit.htm" method="post">
<label>Login <input type="text" name="login" /></label></br>
<label>Password <input type="password" name="pwd" /></label><br />
<input type="submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
<head></head>
<body>
<form>
<label>Login <input type="text" name="login" /></label></br>
<label>New Password <input type="password" name="pwd" autocomplete="new-password" /></label><br />
<input type="submit">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这不完全是“如何使用 autocomplete=new-password”的重复,因为行为似乎已经改变或记录不全。
我有一个关联数组,如下所示:
$sensorThreshold = [
'ph' => [
'minPh' => $sensorThreshold->where('name', 'Ph')->last()->min_threshold ?? 0,
'maxPh' => $sensorThreshold->where('name', 'Ph')->last()->max_threshold ?? 0,
'sum' => $sensorThreshold->where('name', 'Ph')->last()->min_threshold + $sensorThreshold->where('name', 'Ph')->last()->max_threshold,
]
]
Run Code Online (Sandbox Code Playgroud)
当我定义数组时如何访问minPh
和值?maxPh
喜欢:
$sensorThreshold = [
'ph' => [
'minPh' => $sensorThreshold->where('name', 'Ph')->last()->min_threshold ?? 0,
'maxPh' => $sensorThreshold->where('name', 'Ph')->last()->max_threshold ?? 0,
'sum' => minPh + maxPh,
]
]
Run Code Online (Sandbox Code Playgroud)