Saturday 15 January 2011

php - Trying to make an authentication view for GET route but not POST in Laravel 4.2 -


edit:

I've found that when the URLs are the same, the post is not the same Filling the used form also redirects the user to see auth, though its method is set to POST. It appears that the form method was set to GET, or I have defined a root :: any on that URL I neither

the main question :

So, there is a scene inside of my app that only the user should have access to a specific password (not their password as a user) and a specific e-mail. To accomplish this, I put one form in another view (accessible to everyone) and created a POST route as follows:

teamv5.blade.php

< Pre> & lt; Form Action = "{{URL :: Way ('Team-Update-V5-Post', Array ('V5', $ Team_v5-> TeamName))}}" Method = 'Post' & gt; & Lt; P & gt; Team Password: {{$ team_v5- & gt; TeamName}} & lt; / P & gt; & Lt; Input type = 'password' name = 'password' & gt; & Lt; Input type = 'hidden' name = 'email' value = "{{Sentry :: getUser () -> email}}" & gt; & Lt; Input type = 'submit' value = 'edit' & gt; {{Form :: token (); }} & Lt; / Form & gt;

Routes.FP

  Route: post ('/ sentry / team / {v} / {teamname} / edit', array (' As' = & gt; Team-Update-V5-Post ',' Usage '= & gt; TeamController @ postUpdateV5')); Route: get ('/ sentry / team / {v} / {teamname} / edit', array ('as' = & gt; team-update-v5', 'uses' => teamcontentor @ getUpdateV5 '));  

So if the password is correct and the user's e-mail is authorized to access that view, then it works and the information passes through the controller.

Now, the problem is: I do not want to see anybody with any specific password other than that specific user, so I tried to type the URL in the browser Created the GET route. That route is considered an authentication view that inspires the user to fill in the required information. Here is the controller:

TeamCentron.php

  public function getUpdateV5 ($ v, $ teamname) {return view :: create ('team.auth') - & gt; ; ('V', $ V) - & gt; From ('TeamName', $ TeamName); } Public function postUpdateV5 ($ v, $ teamname) {$ validator = validator :: make (input :: All), array ('password' = & gt; 'required | minimum: 6', 'email' = & gt; 'Required | email',)); If ($ validator- & gt; fails ()) {Redirect: root ('Team-Update-v5', array ('v5', $ TeamName)) - & gt; With partners ($ accredited); } And ($ team_v5 = DB :: table ('teams_v5') -> where ('TeamName', $ TeamName) - & gt; First (); $ Captain_v5 = Sentry :: findUserById ($ team_v5- & gt; Captain_ID; with ('Team_v5', $ team_v5) ('Team .updatev5') -> if (hash :: check (get input: ('password'), $ team_v5- & gt; - & gt; ('Captain_V5', $ captain_v5)} Other {Return Redirect :: Way ('profile-team', array ($ v, $ teamname)) -> ('global', 'wrong password ! '); Finally, what happens:  
  1. If I write the same URL for GET and Post Route, then GET is a work But after filling the first form in teamv5.blade.php , the user is redirected to at the view and prompted to type information (not good). < / Li>
  2. If I write a different URL or just comment on the GET route, the post works perfectly but when I try to reload the page or access the URL, then I HTMF METHOD Permission is not allowed (because, of course, the GET route is written for this URL).

I want the user to reach both ways, if possible. I know I made it for a long time, sorry. Any help would be appreciated.

Thanks in advance!


No comments:

Post a Comment