[Git][noosfero/noosfero][master] 2 commits: Fixes OauthClient plugin, adds signup message

Rodrigo Souto gitlab at mg.gitlab.com
Thu Aug 2 17:26:18 BRT 2018


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
89e70876 by Gabriel Silva at 2018-08-02T16:57:48Z
Fixes OauthClient plugin, adds signup message

Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>

- - - - -
57fc986e by Rodrigo Souto at 2018-08-02T20:26:13Z
Merge branch 'oauth-client-signup-2' into 'master'

[master/OauthPlugin] User fixes, improvements on signup page

See merge request noosfero/noosfero!1590
- - - - -


7 changed files:

- plugins/oauth_client/lib/ext/user.rb
- plugins/oauth_client/lib/oauth_client_plugin.rb
- − plugins/oauth_client/public/style.css
- + plugins/oauth_client/public/style.scss
- plugins/oauth_client/test/functional/oauth_client_plugin_account_controller_test.rb
- plugins/oauth_client/views/account/_oauth_signup.html.erb
- + plugins/oauth_client/views/account/signup.html.erb


Changes:

=====================================
plugins/oauth_client/lib/ext/user.rb
=====================================
@@ -32,7 +32,7 @@ class User
   alias_method_chain :password_required?, :oauth
 
   def make_activation_codes_with_oauth
-    @oauth_providers.blank? && oauth_providers.blank? ? make_activation_code_without_oauth : nil
+    @oauth_providers.blank? && oauth_providers.blank? ? make_activation_codes_without_oauth : nil
   end
 
   alias_method_chain :make_activation_codes, :oauth


=====================================
plugins/oauth_client/lib/oauth_client_plugin.rb
=====================================
@@ -90,8 +90,9 @@ class OauthClientPlugin < Noosfero::Plugin
 
   def account_controller_filters
     {
-      :type => 'before_filter', :method_name => 'signup',
-      :block => proc {
+      type: 'before_filter', method_name: 'check_email_on_oauth_signup',
+      options: { only: :signup },
+      block: proc {
         auth = session[:oauth_data]
 
         if auth.present? && params[:user].present?
@@ -105,7 +106,6 @@ class OauthClientPlugin < Noosfero::Plugin
   end
 
   def js_files
-  ["script.js"]
+    ["script.js"]
   end
-
 end


=====================================
plugins/oauth_client/public/style.css deleted
=====================================
@@ -1,22 +0,0 @@
-.oauth-login .provider a {
-  min-width: 20px;
-  min-height: 20px;
-  background-size: 20px;
-  display: inline-block;
-  text-decoration: none;
-  background-repeat: no-repeat;
-  line-height: 20px;
-}
-.oauth-login .provider a img {
-  max-width: 40px;
-}
-.oauth-login .provider a:hover {
-  opacity: 0.7;
-}
-.oauth-login .provider .developer {
-  display: none;
-}
-
-.remember-enable-email.hidden {
-  display: none;
-}


=====================================
plugins/oauth_client/public/style.scss
=====================================
@@ -0,0 +1,38 @@
+.oauth-login .provider {
+  a {
+    min-width: 20px;
+    min-height: 20px;
+    background-size: 20px;
+    display: inline-block;
+    text-decoration: none;
+    background-repeat: no-repeat;
+    line-height: 20px;
+
+    img {
+      max-width: 40px;
+    }
+
+    &:hover {
+      opacity: 0.7;
+    }
+  }
+
+  .developer {
+    display: none;
+  }
+}
+
+.remember-enable-email.hidden {
+  display: none;
+}
+
+#oauth-signup {
+  #signup-password-section {
+    display: none;
+  }
+
+  #signup-email input {
+    pointer-events: none;
+    opacity: 0.5;
+  }
+}


=====================================
plugins/oauth_client/test/functional/oauth_client_plugin_account_controller_test.rb
=====================================
@@ -1,9 +1,19 @@
 require 'test_helper'
 
 class AccountControllerTest < ActionController::TestCase
+  def setup
+    Environment.default.enable_plugin OauthClientPlugin
+  end
 
-  should 'render signup page' do
+  should 'not render custom div if session does not contain auuth' do
+    session[:oauth_data] = nil
     get :signup
+    assert_no_tag :div, attributes: { id: 'oauth-signup' }
   end
 
+  should 'render custom div if session contains auuth' do
+    session[:oauth_data] = { something: 'something' }
+    get :signup
+    assert_tag :div, attributes: { id: 'oauth-signup' }
+  end
 end


=====================================
plugins/oauth_client/views/account/_oauth_signup.html.erb
=====================================
@@ -1,11 +1 @@
 <%= hidden_field_tag 'return_to', '/' %>
-
-<style>
-  #signup-password, #signup-password-confirmation, #signup-email {
-    display: none;
-  }
-</style>
-
-<div id='signup-email-readonly'>
-  <%= labelled_form_field(_('Email'), text_field(:user, :email, :class => "disabled", :readonly => true)) %>
-</div>


=====================================
plugins/oauth_client/views/account/signup.html.erb
=====================================
@@ -0,0 +1,19 @@
+<% if session[:oauth_data].present? %>
+  <h1><%= _('Finish your registration.') % environment.name %></h1>
+  <p><%= _('It is the first time you sign in, so we need some information '\
+           'to create your profile.') %></p>
+
+  <div id='oauth-signup'>
+    <div id='signup-intro'>
+      <%= environment.signup_intro.try(:html_safe) %>
+    </div>
+    <%= render :partial => 'signup_form' %>
+  </div>
+<% else %>
+  <h1><%= _('Sign up for %s!') % environment.name %></h1>
+
+  <div id='signup-intro'>
+    <%= environment.signup_intro.try(:html_safe) %>
+  </div>
+  <%= render :partial => 'signup_form' %>
+<% end %>



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/cb53540c2b09eaf295e4cbf063f149cf063f6cf4...57fc986e14528bdb5cd8bc4555fbfe3d3f47c928

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/cb53540c2b09eaf295e4cbf063f149cf063f6cf4...57fc986e14528bdb5cd8bc4555fbfe3d3f47c928
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180802/4ed291b0/attachment-0001.html>


More information about the Noosfero-dev mailing list