Browse Source

Styled the templates, re-added the form login and added the connect link

Christophe Coevoet 12 years ago
parent
commit
229e306a09

+ 3 - 0
app/Resources/FOSUserBundle/views/Profile/show.html.twig

@@ -7,6 +7,9 @@
         <h1>{{ user.username }} (that's you!)</h1>
         <p><a href="{{ path('fos_user_profile_edit') }}">Edit your information</a></p>
         <p><a href="{{ path('fos_user_change_password') }}">Change your password</a></p>
+        {% if not user.githubId %}
+        <p><a href="{{ path('hwi_oauth_connect_service', {'service': 'github'}) }}">Connect your github account</a></p>
+        {% endif %}
         <p><a href="{{ path('user_profile', {'name':app.user.username}) }}">View your public profile</a></p>
 
         {% if app.user.apiToken %}

+ 31 - 0
app/Resources/HWIOAuthBundle/views/Connect/login.html.twig

@@ -0,0 +1,31 @@
+{% extends 'HWIOAuthBundle::layout.html.twig' %}
+
+{% block hwi_oauth_content %}
+    {% if error %}
+        <div>{{ error }}</div>
+    {% endif %}
+    {% for owner in hwi_oauth_resource_owners() %}
+    <a class="submit" href="{{ hwi_oauth_login_url(owner) }}">Login with {{ owner | trans({}, 'HWIOAuthBundle') }}</a> <br />
+    {% endfor %}
+
+    <form action="{{ path('login_check') }}" method="post">
+        <div>
+            <label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
+            <input type="text" id="username" name="_username" />
+        </div>
+
+        <div>
+            <label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
+            <input type="password" id="password" name="_password" />
+        </div>
+
+        <div>
+            <input type="checkbox" id="remember_me" name="_remember_me" value="on" checked="checked" />
+            <label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
+        </div>
+
+        <input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
+    </form>
+
+    <a href="{{ path('fos_user_resetting_request') }}">Forgot password?</a>
+{% endblock hwi_oauth_content %}

+ 7 - 0
app/Resources/HWIOAuthBundle/views/layout.html.twig

@@ -0,0 +1,7 @@
+{% extends 'PackagistWebBundle::layout.html.twig' %}
+
+{% block content %}
+    <div class="box clearfix">
+        {% block hwi_oauth_content %}{% endblock %}
+    </div>
+{% endblock %}

+ 2 - 1
src/Packagist/WebBundle/Form/Handler/OAuthRegistrationFormHandler.php

@@ -57,12 +57,13 @@ class OAuthRegistrationFormHandler implements RegistrationFormHandlerInterface
             if ($form->isValid()) {
                 $randomPassword = $this->tokenGenerator->generateToken();
                 $user->setPlainPassword($randomPassword);
+                $user->setEnabled(true);
 
                 return true;
             }
         // if the form is not posted we'll try to set some properties
         } else {
-            $user->setUsername($this->getUniqueUsername($userInformation->getUsername()));
+            $user->setUsername($this->getUniqueUsername($userInformation->getNickname()));
 
             if ($userInformation instanceof AdvancedUserResponseInterface) {
                 $user->setEmail($userInformation->getEmail());