Fernando Löpez Fernando Löpez - 25 days ago 9
MySQL Question

restrict acces to "my account" only from a certain page in Laravel

Im working on an application in Laravel and I have to create some restriction only when Im in "subusers" page... that means:

-if Im in subusers page and click the button "go to my account" I have to display a securityCheck (which I have and it is working) a form with a "write username and password"

-Otherwise account page is accesible from other pages.

That should do the job... sounds preety easy right...? well... I have no idea how to do it. Instead I created a granted acces for some minutes (15)

public function getAccounts()
{
$loginTime = new Carbon(Session::get('LoginTime'));
$diff = $loginTime->diffInMinutes(Carbon::now());
//after 15 minutes a password security check will be ask.

if($diff > 15)
{
return redirect('SecurityCheck');
}



if(Auth::check() && $this->user->subscribed()){

$data = array(
'user' =>$this->user,
'users' => $this->user->users(),
'invoices' => $this->user->invoices()
);
//if(session('auth') ==1)
//{
return view('pages.payment.account')->with('data', $data);
//}else{
//$messages =array(
//'1' =>''
//);
//return view('Auth.SecurityCheck')->with('messages', $messages);
//}
}else{
return view('pages.payment.join')->with('user', $this->user);
}
}


this is not working as I want... cause it creates a hole in the securityCheck and I can still access to my account from "subuserspage" before the 15 minutes are over... then it gonna ask securityCheck everytime I click on "my account" (which I dont want... I just want the securityCheck step on the subusers page)

How do I create a restriction to "my account" only from subusers page?

Answer Source
public function getAccounts()
{  

    if(Auth::check() && ($this->user->subscribed() || $this->user->subscribed())){

           $data = array(
        'user'  =>$this->user,
        'users'   => $this->user->users(),
        'invoices' => $this->user->invoices()
        );

        return view('pages.payment.account')->with('data', $data);

    }else{
        return view('pages.payment.join')->with('user', $this->user);
    }
}

The function should see like this and it is solved. Thanks to asll that clicked on minus just to bother.