「ログイン情報を保持する」の機能が実装されておりません。
このコミットが含まれているのは:
コミット
05563ef58c
|
@ -14,6 +14,8 @@ use App\Models\LoginLimits;
|
|||
|
||||
trait AuthenticationTrait {
|
||||
private function makeSession ($guard, $db) {
|
||||
session()->regenerate();
|
||||
|
||||
if (!session()->has($guard)) {
|
||||
// 認証されたデータのpasswordとremember_token以外を把握する
|
||||
unset($db['password']);
|
||||
|
@ -25,6 +27,19 @@ trait AuthenticationTrait {
|
|||
return $db;
|
||||
}
|
||||
|
||||
public function checkSession () {
|
||||
if (isset($_COOKIE['remember_token']) && !is_null($_COOKIE['remember_token'])) { // クッキーがある場合
|
||||
if (null !== ($get = $this->getModel()->where('remember_token', $_COOKIE['remember_token'])->first())) { // トークンがある場合
|
||||
// セッションを想像する
|
||||
$login_user_datum = $this->makeSession($this->getGuard(), $get->toArray());
|
||||
|
||||
return ['status_code' => 200, 'params' => ['id' => $login_user_datum['id']]];
|
||||
}
|
||||
}
|
||||
|
||||
return ['status_code' => 202];
|
||||
}
|
||||
|
||||
public function login (Request $r) {
|
||||
$loginid = $this->getGuard() == 'children' ? $r->tel : $r->email;
|
||||
|
||||
|
@ -38,15 +53,6 @@ trait AuthenticationTrait {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['remember_token']) && !is_null($_COOKIE['remember_token'])) { // クッキーがある場合
|
||||
if (null !== ($get = $this->getModel()->where('remember_token', $_COOKIE['remember_token'])->first())) { // トークンがある場合
|
||||
// セッションを想像する
|
||||
$login_user_datum = $this->makeSession($this->getGuard(), $get->toArray());
|
||||
|
||||
return ['status_code' => 200, 'params' => ['id' => $login_user_datum['id']]];
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->getGuard() == 'children') {
|
||||
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
|
||||
return $this->telsize($value);
|
||||
|
@ -95,6 +101,8 @@ trait AuthenticationTrait {
|
|||
if (Session::has('children')) Session::forget('children');
|
||||
if (Session::has('fathers')) Session::forget('fathers');
|
||||
if (Session::has('admins')) Session::forget('admins');
|
||||
unset($_COOKIE['remember_token']);
|
||||
setcookie('remember_token', '', time() - 3600, '/', $_SERVER['HTTP_HOST'], 0, 1);
|
||||
|
||||
if ($r->remember_token == 'true') {
|
||||
$token = bin2hex(random_bytes(24));
|
||||
|
|
|
@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Storage;
|
|||
use App\Models\Child;
|
||||
use App\Models\Father;
|
||||
use App\Models\FatherRelation;
|
||||
use App\Models\Meeting;
|
||||
use App\Models\MeetingApprovals;
|
||||
use App\Models\TelActivation;
|
||||
|
||||
|
@ -196,12 +197,27 @@ class ChildrenController extends Controller {
|
|||
|
||||
if (!is_null($telact->father_id)) {
|
||||
$rel = new FatherRelation;
|
||||
|
||||
$add = [
|
||||
'father_id' => $telact->father_id,
|
||||
'child_id' => $child->id,
|
||||
'hire_at' => date('Y-m-d H:i:s', time()),
|
||||
];
|
||||
|
||||
if (null !== ($meet = Meeting::select('id')->where('father_id', $telact->father_id)->where('is_favorite', true)->get())) {
|
||||
foreach ($meet as $m) {
|
||||
$app = new MeetingApprovals;
|
||||
|
||||
$join = [
|
||||
'child_id' => $child->id,
|
||||
'meeting_id' => $m->id,
|
||||
];
|
||||
|
||||
$app->fill($join);
|
||||
$app->push();
|
||||
}
|
||||
}
|
||||
|
||||
$rel->fill($add);
|
||||
$rel->push();
|
||||
}
|
||||
|
|
ファイル差分が大きすぎるため省略します
差分を読み込み
|
@ -33,7 +33,7 @@ return [
|
|||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => false,
|
||||
'expire_on_close' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
長すぎる行があるためファイル差分は表示されません
長すぎる行があるためファイル差分は表示されません
|
@ -22,6 +22,26 @@ const AdminLogin = () => {
|
|||
|
||||
useEffect(() => {
|
||||
isMountedRef.current = false;
|
||||
|
||||
axios.post('/api/admin/checkSession').then(response => {
|
||||
if (isMountedRef.current) return;
|
||||
|
||||
switch (response.data.status_code) {
|
||||
case 200: {
|
||||
localStorage.setItem('kiki_login_flag', true);
|
||||
localStorage.setItem('kiki_acc_type', 'admin');
|
||||
localStorage.setItem('kiki_acc_id', response.data.params.id);
|
||||
setCookie('logged', 'success');
|
||||
if (location.search == '')
|
||||
window.location.href = "/admin/meeting";
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMountedRef.current = true;
|
||||
}
|
||||
|
@ -51,11 +71,11 @@ const AdminLogin = () => {
|
|||
localStorage.setItem('kiki_login_flag', true);
|
||||
localStorage.setItem('kiki_acc_type', 'admin');
|
||||
setCookie('logged', 'success');
|
||||
if(location.search == '')
|
||||
if(location.search == '')
|
||||
window.location.href = "/admin/meeting";
|
||||
else
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 422: {
|
||||
|
|
|
@ -22,6 +22,26 @@ const ChildLogin = () => {
|
|||
const isMountedRef = useRef(true);
|
||||
useEffect(() => {
|
||||
isMountedRef.current = false;
|
||||
|
||||
axios.post('/api/children/checkSession').then(response => {
|
||||
if (isMountedRef.current) return;
|
||||
|
||||
switch (response.data.status_code) {
|
||||
case 200: {
|
||||
localStorage.setItem('kiki_login_flag', true);
|
||||
localStorage.setItem('kiki_acc_type', 'c-account');
|
||||
localStorage.setItem('kiki_acc_id', response.data.params.id);
|
||||
setCookie('logged', 'success');
|
||||
if (location.search == '')
|
||||
window.location.href = "/c-account/meeting";
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMountedRef.current = true;
|
||||
}
|
||||
|
@ -48,9 +68,9 @@ const ChildLogin = () => {
|
|||
localStorage.setItem('kiki_acc_type', 'c-account');
|
||||
localStorage.setItem('kiki_acc_id', response.data.params.id);
|
||||
setCookie('logged', 'success');
|
||||
if(location.search == '')
|
||||
if(location.search == '')
|
||||
window.location.href = "/c-account/meeting";
|
||||
else
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
break;
|
||||
}
|
||||
|
@ -129,4 +149,4 @@ const ChildLogin = () => {
|
|||
|
||||
|
||||
|
||||
export default ChildLogin;
|
||||
export default ChildLogin;
|
||||
|
|
|
@ -24,11 +24,30 @@ const ParentLogin = () => {
|
|||
const isMountedRef = useRef(true);
|
||||
useEffect(() => {
|
||||
isMountedRef.current = false;
|
||||
|
||||
axios.post('/api/fathers/checkSession').then(response => {
|
||||
if (isMountedRef.current) return;
|
||||
|
||||
switch (response.data.status_code) {
|
||||
case 200: {
|
||||
localStorage.setItem('kiki_login_flag', true);
|
||||
localStorage.setItem('kiki_acc_type', 'p-account');
|
||||
localStorage.setItem('kiki_acc_id', response.data.params.id);
|
||||
setCookie('logged', 'success');
|
||||
if (location.search == '')
|
||||
window.location.href = "/p-account/meeting";
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMountedRef.current = true;
|
||||
}
|
||||
}, [])
|
||||
|
||||
}, []);
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
@ -51,9 +70,9 @@ const ParentLogin = () => {
|
|||
localStorage.setItem('kiki_acc_type', 'p-account');
|
||||
localStorage.setItem('kiki_acc_id', response.data.params.id);
|
||||
setCookie('logged', 'success');
|
||||
if(location.search == '')
|
||||
if(location.search == '')
|
||||
window.location.href = "/p-account/meeting";
|
||||
else
|
||||
else
|
||||
window.location.href = location.search.replace('?redirect_to=', '');
|
||||
break;
|
||||
}
|
||||
|
@ -132,4 +151,4 @@ const ParentLogin = () => {
|
|||
|
||||
|
||||
|
||||
export default ParentLogin;
|
||||
export default ParentLogin;
|
||||
|
|
|
@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Route;
|
|||
Route::group(['prefix' => 'admin'], function () {
|
||||
// AdminController
|
||||
Route::post('/login', '\App\Http\Controllers\Api\AdminController@login');
|
||||
Route::post('/checkSession', '\App\Http\Controllers\Api\AdminController@checkSession');
|
||||
|
||||
Route::group(['middleware' => 'auth:admins'], function () {
|
||||
// AdminController
|
||||
|
@ -88,6 +89,7 @@ Route::group(['prefix' => 'fathers'], function () {
|
|||
Route::post('/registerMain', '\App\Http\Controllers\Api\FathersController@registerMain');
|
||||
Route::post('/requestPassword', '\App\Http\Controllers\Api\FathersController@requestPassword');
|
||||
Route::post('/login', '\App\Http\Controllers\Api\FathersController@login');
|
||||
Route::post('/checkSession', '\App\Http\Controllers\Api\FathersController@checkSession');
|
||||
Route::put('/updatePassword/{father_id?}', '\App\Http\Controllers\Api\FathersController@updatePassword')->name('ppp');
|
||||
|
||||
Route::group(['middleware' => ['auth:fathers', 'notice.incomplete']], function () {
|
||||
|
@ -159,6 +161,7 @@ Route::group(['prefix' => 'children'], function () {
|
|||
Route::post('/registerMain', '\App\Http\Controllers\Api\ChildrenController@registerMain');
|
||||
Route::post('/requestPassword', '\App\Http\Controllers\Api\ChildrenController@requestPassword');
|
||||
Route::post('/login', '\App\Http\Controllers\Api\ChildrenController@login');
|
||||
Route::post('/checkSession', '\App\Http\Controllers\Api\ChildrenController@checkSession');
|
||||
Route::put('/updatePassword/{child_id?}', '\App\Http\Controllers\Api\ChildrenController@updatePassword')->name('cpc');
|
||||
|
||||
// FatherRelationsController
|
||||
|
|
新しいイシューから参照