我正在使用自定义方法来验证用户身份。在验证用户身份时,我在会话中输入了一些数据。我要插入的数据是数组/对象。但是如果数组大小超过8,我就会面临一个问题。如果我放入9个数组数据,它就会让我退出(会话可能会有一些问题)。找不到这背后的原因。有谁能帮帮我吗?
这是我的数组/对象结构。
[0] => stdClass Object
(
[privileges_of_role_id] => 1
[role_id] => 4
[institute_branch_version_id] => 1
[is_active] => 1
)我正在处理的验证用户的方法:
public function signInAction(Request $request)
{
if (!$request->ajax()) {
$validator = Validator::make($request->all(), array(
'identifiers' => 'required|max:255',
'password' => 'required|max:20'
));
if ($validator->fails()) {
return redirect()->back()
->withErrors($validator)
->withInput();
}
try {
$loginBy = NULL;
$loginByValue = $request->identifiers;
if (is_numeric($loginByValue)) {
if (strlen($loginByValue) > 3 && substr($loginByValue, 0, 3)) {
$loginBy = 'phone_no';
} else {
$loginBy = 'user_id';
}
} else if (filter_var($loginByValue, FILTER_VALIDATE_EMAIL)) {
$loginBy = 'email';
} else {
$loginBy = 'username';
}
} catch (\Exception $ex) {
echo $ex->getMessage();
}
$loginCredentials = array(
$loginBy => $loginByValue,
'password' => $request->password,
'is_active' => 1
);
if (Auth::attempt($loginCredentials)) {
$PrivilegesOfRole = DB::table('tbl_privileges_of_roles')
->where('role_id', Auth::user()->role_id)
->where('is_active', 1)
->take(8) // if i take 9, its not letting me logged in.
->get();
$request->session()->put('PrivilegesOfRole', $PrivilegesOfRole);
return redirect()->intended(route('home::onlineInfo'));
} else {
return redirect()->back()
->with('errorMessage', 'The identifiers and password you entered don\'t match.')
->withInput();
}
} else {
throw new Exception('Invalid request!');
}
}发布于 2020-01-25 15:09:35
https://stackoverflow.com/questions/59907071
复制相似问题