Here's a pretty awesome blog I just found it particularly explains how to insert login form in the frontend.
http://www.clementdelmas.fr/blog/developpement-web/symfony/formulaire-dauthentification-pour-frontend-avec-sfguardplugin/comment-page-1 # comment-9
Form authentication frontend with sfGuardPlugin
In the series "I dug up tutorials that I wrote last year" Here is a tutorial for symfony . It was written for 1.2 but I still think it should be compatible to 1.4 (to check anyway). The purpose of this tutorial is to show you how to simply and quickly, a form of authentication for the frontend application in a component, all with sfGuardPlugin (phew!). I invite you to read the passage, the plugin documentation and excerpt from guide to symfony 1.2 , which will always help you / supplement this article.Creating component
We create a component that contains the action code we want to execute the partial. To do this, create a new file in the module components.class.php related component (File sfGuardAuth / shares). Then edit the file and add the creation of the form:\u0026lt;?
php class extends sfGuardAuthComponents sfComponents
{
public function executeSideSignin ($ request) {
$ Class = sfConfig:: get ('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$ this-> signinForm = new $ class ();}
}
? >
Creation of the template is created from the template component (in our case _sideSignin.php sfGuardAuth in the folder / templates)
that will display the login form, and it publishes:
\u0026lt;h2> Identification Form \u0026lt;/ h2>; include_component ('sfGuardAuth', 'sideSignin');>
\u0026lt;form id = "signinForm" action = "\u0026lt;? php echo url_for('@sf_guard_signin') ?>" method="post" class="clearfix">
<div id="signinFields">
<label for="signin_username">Login</label>
<input type="text" name="signin[username]" id="signin_username" />
<br />
<label for="signin_password">Mot de passe</label>
<input type="password" name="signin[password]" id="signin_password" />
<br />
<input type = "checkbox" name = "contemporary design [remember]," id = "signin_remember" />
\u0026lt;Label for="signin_remember"> The souvenir de moi \u0026lt; ; / label>
\u0026lt;/ div> \u0026lt;div
id="signinSubmit">
\u0026lt; ? php echo $ signinForm-> renderHiddenFields ();
?>
\u0026lt;! - A href ="#"> Forgot your password? \u0026lt;/ A> 'SideSignin');
", cache and refresh the page ...
To test whether the user is already authenticated, it uses this function:
if (! $ Sf_user-> isAuthenticated ())
0 comments:
Post a Comment