user_mgmt 0.0.52 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +58 -6
  3. data/README.md +10 -2
  4. data/app/assets/javascripts/user_mgmt/registrations.js +2 -0
  5. data/app/assets/javascripts/user_mgmt/sessions.js +2 -0
  6. data/app/assets/stylesheets/user_mgmt/{application.css → application.css.scss} +1 -0
  7. data/app/assets/stylesheets/user_mgmt/registrations.css +34 -0
  8. data/app/assets/stylesheets/user_mgmt/sessions.css +4 -0
  9. data/app/controllers/user_mgmt/application_controller.rb +97 -0
  10. data/app/controllers/user_mgmt/registrations_controller.rb +32 -0
  11. data/app/controllers/user_mgmt/sessions_controller.rb +81 -0
  12. data/app/helpers/user_mgmt/application_helper.rb +5 -0
  13. data/app/helpers/user_mgmt/registrations_helper.rb +4 -0
  14. data/app/helpers/user_mgmt/sessions_helper.rb +4 -0
  15. data/app/models/user_mgmt/user.rb +15 -0
  16. data/app/views/layouts/user_mgmt/application.html.haml +17 -0
  17. data/app/views/user_mgmt/registrations/_user_form.html.haml +3 -6
  18. data/app/views/user_mgmt/registrations/edit.html.haml +5 -0
  19. data/app/views/user_mgmt/registrations/new.html.haml +18 -6
  20. data/app/views/user_mgmt/sessions/new.html.haml +30 -0
  21. data/app/views/user_mgmt/sessions/oauth_email.html.haml +11 -0
  22. data/config/routes.rb +15 -1
  23. data/lib/generators/templates/README +18 -2
  24. data/lib/generators/templates/user_mgmt.rb +28 -1
  25. data/lib/generators/user_mgmt/install_generator.rb +6 -0
  26. data/lib/user_mgmt/engine.rb +22 -0
  27. data/lib/user_mgmt/version.rb +1 -1
  28. data/lib/user_mgmt.rb +1 -6
  29. data/test/controllers/user_mgmt/registrations_controller_test.rb +16 -0
  30. data/test/controllers/user_mgmt/sessions_controller_test.rb +21 -0
  31. data/test/dummy/app/assets/javascripts/simulate.js +2 -0
  32. data/test/dummy/app/assets/stylesheets/simulate.css +4 -0
  33. data/test/dummy/app/controllers/application_controller.rb +3 -0
  34. data/test/dummy/app/controllers/simulate_controller.rb +5 -0
  35. data/test/dummy/app/helpers/simulate_helper.rb +2 -0
  36. data/test/dummy/app/views/layouts/application.html.haml +17 -0
  37. data/test/dummy/app/views/simulate/index.html.haml +12 -0
  38. data/test/dummy/config/initializers/user_mgmt.rb +37 -0
  39. data/test/dummy/config/routes.rb +4 -1
  40. data/test/dummy/test/controllers/simulate_controller_test.rb +9 -0
  41. data/test/dummy/test/helpers/simulate_helper_test.rb +4 -0
  42. data/test/helpers/user_mgmt/registrations_helper_test.rb +6 -0
  43. data/test/helpers/user_mgmt/sessions_helper_test.rb +6 -0
  44. data/user_mgmt.gemspec +18 -10
  45. metadata +180 -20
  46. data/app/controllers/user_mgmt_controller.rb +0 -4
  47. data/app/views/layouts/user_mgmt/application.html.erb +0 -14
  48. data/lib/user_mgmt/configurator.rb +0 -8
  49. data/test/dummy/app/views/layouts/application.html.erb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7ebea96dc9549cad51b432eebfa552352f4075e
4
- data.tar.gz: a9b967f955462a9e4148dc897d35adc132b0bd70
3
+ metadata.gz: 6a5c2bd299dafff13cee9a059b952c699d962049
4
+ data.tar.gz: 8e9cb1c9855713a8a781222a1dd7134dacf5fe76
5
5
  SHA512:
6
- metadata.gz: 57ab3aacd309d05716e01e53259509f8ca6ff9dd7d837381c30a2e3507e95a2f8051d5f283066bf9834a0e8322c81ad65079c6540ddb7bd3a82b261f90cb412b
7
- data.tar.gz: 16854c7635a40183c438582f19631553b45b7ea32e6e5d0dd7db8d2951911655453cc75957132240f6936a0a8eb6a90e3c381148443eab7b17422d6d94bc23f2
6
+ metadata.gz: ecabaed49da560c0bd3790b55b1678e662057f37180518e8faf6da889f685e9283aba07ccef1dc8e631d72e274ef6843336849a54fb658230ff91181107e1e5f
7
+ data.tar.gz: c4b6d3f89129f40452171e1aa7bd9a6a48f2d4dfdd855c4bbe3f822e81b047201cde365eb1a02a5496a9e30534627d8f7431f86a9f4e1d52fede41453df9144b
data/Gemfile.lock CHANGED
@@ -1,7 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- user_mgmt (0.0.513)
4
+ user_mgmt (0.0.616)
5
+ bootstrap-sass
6
+ haml
7
+ haml-rails
8
+ omniauth
9
+ omniauth-facebook
10
+ omniauth-google-oauth2
11
+ omniauth-linkedin
12
+ omniauth-twitter
13
+ omniauth-windowslive
14
+ omniauth-yahoo
15
+ rails
16
+ sass-rails
5
17
 
6
18
  GEM
7
19
  remote: https://rubygems.org/
@@ -32,9 +44,13 @@ GEM
32
44
  tzinfo (~> 0.3.37)
33
45
  arel (4.0.0)
34
46
  atomic (1.1.10)
47
+ bootstrap-sass (2.3.2.1)
48
+ sass (~> 3.2)
35
49
  builder (3.1.4)
36
50
  diff-lcs (1.2.4)
37
51
  erubis (2.7.0)
52
+ faraday (0.8.8)
53
+ multipart-post (~> 1.2.0)
38
54
  genspec (0.2.8)
39
55
  rspec (~> 2)
40
56
  sc-core-ext (~> 1.2.1)
@@ -46,14 +62,50 @@ GEM
46
62
  activesupport (>= 3.1, < 4.1)
47
63
  haml (>= 3.1, < 4.1)
48
64
  railties (>= 3.1, < 4.1)
65
+ hashie (2.0.5)
49
66
  hike (1.2.3)
67
+ httpauth (0.2.0)
50
68
  i18n (0.6.4)
69
+ jwt (0.1.8)
70
+ multi_json (>= 1.5)
51
71
  mail (2.5.4)
52
72
  mime-types (~> 1.16)
53
73
  treetop (~> 1.4.8)
54
74
  mime-types (1.23)
55
75
  minitest (4.7.5)
56
76
  multi_json (1.7.7)
77
+ multipart-post (1.2.0)
78
+ oauth (0.4.7)
79
+ oauth2 (0.8.1)
80
+ faraday (~> 0.8)
81
+ httpauth (~> 0.1)
82
+ jwt (~> 0.1.4)
83
+ multi_json (~> 1.0)
84
+ rack (~> 1.2)
85
+ omniauth (1.1.4)
86
+ hashie (>= 1.2, < 3)
87
+ rack
88
+ omniauth-facebook (1.4.1)
89
+ omniauth-oauth2 (~> 1.1.0)
90
+ omniauth-google-oauth2 (0.2.0)
91
+ omniauth (~> 1.0)
92
+ omniauth-oauth2
93
+ omniauth-linkedin (0.1.0)
94
+ omniauth-oauth (~> 1.0)
95
+ omniauth-oauth (1.0.1)
96
+ oauth
97
+ omniauth (~> 1.0)
98
+ omniauth-oauth2 (1.1.1)
99
+ oauth2 (~> 0.8.0)
100
+ omniauth (~> 1.0)
101
+ omniauth-twitter (1.0.0)
102
+ multi_json (~> 1.3)
103
+ omniauth-oauth (~> 1.0)
104
+ omniauth-windowslive (0.0.8.1)
105
+ multi_json (>= 1.0.3)
106
+ omniauth-oauth2 (~> 1.0)
107
+ omniauth-yahoo (0.0.4)
108
+ omniauth-oauth (~> 1.0)
57
109
  polyglot (0.3.3)
58
110
  rack (1.5.2)
59
111
  rack-test (0.6.2)
@@ -80,6 +132,11 @@ GEM
80
132
  rspec-expectations (2.14.0)
81
133
  diff-lcs (>= 1.1.3, < 2.0)
82
134
  rspec-mocks (2.14.1)
135
+ sass (3.2.10)
136
+ sass-rails (4.0.0)
137
+ railties (>= 4.0.0.beta, < 5.0)
138
+ sass (>= 3.1.10)
139
+ sprockets-rails (~> 2.0.0)
83
140
  sc-core-ext (1.2.1)
84
141
  activesupport (>= 2.3.5)
85
142
  sprockets (2.10.0)
@@ -100,8 +157,6 @@ GEM
100
157
  polyglot
101
158
  polyglot (>= 0.3.1)
102
159
  tzinfo (0.3.37)
103
- warden (1.2.3)
104
- rack (>= 1.0)
105
160
 
106
161
  PLATFORMS
107
162
  ruby
@@ -110,10 +165,7 @@ DEPENDENCIES
110
165
  bundler (~> 1.3)
111
166
  genspec
112
167
  haml
113
- haml-rails
114
- rails
115
168
  rake
116
169
  rspec
117
170
  sqlite3
118
171
  user_mgmt!
119
- warden
data/README.md CHANGED
@@ -16,11 +16,19 @@ Then you have to run the generator:
16
16
 
17
17
  rails generate user_mgmt:install
18
18
 
19
- This generator will install an initializer which describes all the gem's configuration options and you must take a look at it.
19
+ This generator will install an initializer which describes all the gem's configuration options and you must take a look at it.
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ The gem includes some views (with their respective controllers) that are gonna be used by many distinct apps.
24
+
25
+ In order to use the gem's views, you have to refer to them by:
26
+
27
+ user_mgmt.<route path>
28
+
29
+ Which can be "log_in_path", "sign_up_path" and "log_out_path" (more to be added in the future), e.g:
30
+
31
+ user_mgmt.log_in_path
24
32
 
25
33
  ## Contributing
26
34
 
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -11,3 +11,4 @@
11
11
  *= require_self
12
12
  *= require_tree .
13
13
  */
14
+ @import "bootstrap";
@@ -0,0 +1,34 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+ body {
6
+ padding-top: 40px;
7
+ padding-bottom: 40px;
8
+ background-color: #f5f5f5;
9
+ }
10
+
11
+ .form-signin {
12
+ max-width: 300px;
13
+ padding: 19px 29px 29px;
14
+ margin: 0 auto 20px;
15
+ background-color: #fff;
16
+ border: 1px solid #e5e5e5;
17
+ -webkit-border-radius: 5px;
18
+ -moz-border-radius: 5px;
19
+ border-radius: 5px;
20
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
21
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
22
+ box-shadow: 0 1px 2px rgba(0,0,0,.05);
23
+ }
24
+ .form-signin .form-signin-heading,
25
+ .form-signin .checkbox {
26
+ margin-bottom: 10px;
27
+ }
28
+ .form-signin input[type="text"],
29
+ .form-signin input[type="password"] {
30
+ font-size: 16px;
31
+ height: auto;
32
+ margin-bottom: 15px;
33
+ padding: 7px 9px;
34
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,4 +1,101 @@
1
1
  module UserMgmt
2
2
  class ApplicationController < ActionController::Base
3
+ require "net/http"
4
+ require "uri"
5
+
6
+ def main_page
7
+ redirect_to main_app.root_path
8
+ end
9
+
10
+ private
11
+ def current_user
12
+ @current_user ||= nil#User.find(session[:user_session_id]) if session[:user_session_id]
13
+ end
14
+ helper_method :current_user
15
+
16
+ def sign_up email, password, password_confirmation, host= UserMgmt.external_database_URI
17
+ send_request :post, :users, { user: { email: email, password: password,
18
+ password_confirmation: password_confirmation }, method: :simple }, host
19
+ end
20
+
21
+ def sign_up_oauth uid, strategy, email, host= UserMgmt.external_database_URI
22
+ send_request :post, :users, { user: { uid: uid, strategy: strategy, email: email }, method: :oauth }, host
23
+ end
24
+
25
+ def log_in email, password, host= UserMgmt.external_database_URI
26
+ send_request :get, :login, { user: { email: email, password: password }, method: :simple }, host
27
+ end
28
+
29
+ def log_in_oauth uid, strategy, host= UserMgmt.external_database_URI
30
+ send_request :get, :login, { user: { uid: uid, strategy: strategy }, method: :oauth }, host
31
+ end
32
+
33
+ def log_out umid, host= UserMgmt.external_database_URI
34
+ send_request :delete, :logout, { user: umid }, host
35
+ end
36
+
37
+ def add_strategy uid, strategy, umid, session, host= UserMgmt.external_database_URI
38
+ send_request :post, :add_strategy, { new_strategy: { uid: uid, strategy: strategy },
39
+ user: umid, session_id: session }, host
40
+ end
41
+
42
+ def remove_strategy umid, strategy, session, host= UserMgmt.external_database_URI
43
+ send_request :delete, :remove_strategy, { user: umid, strategy: strategy,
44
+ session_id: session }, host
45
+ end
46
+
47
+ def delete_user umid, session, host= UserMgmt.external_database_URI
48
+ send_request :delete, :destroy, { user: umid, session_id: session }, host
49
+ end
50
+
51
+ def change_password user, password, new_pw, new_pw_confirm, session, host= UserMgmt.external_database_URI
52
+ send_request :put, :change_password, { user: user, password: password,
53
+ new_password: new_pw, new_password_confirmation: new_pw_confirm,
54
+ session: session }, host
55
+ end
56
+
57
+ def reset_password reset_token, new_pw, new_pw_confirm, host= UserMgmt.external_database_URI
58
+ send_request :put, :change_password, { reset_token: reset_token, new_password: new_pw,
59
+ new_password_confirmation: new_pw_confirm }, host
60
+ end
61
+
62
+ def reset_password_request email, host= UserMgmt.external_database_URI
63
+ send_request :post, :reset_password, { email: email }, host
64
+ end
65
+
66
+ def change_email user, password, new_email, new_email_confirm, session, host= UserMgmt.external_database_URI
67
+ send_request :put, :change_email, { email: user, password: password, new_email: new_email,
68
+ new_email_confirmation: new_email_confirm, session: session }, host
69
+ end
70
+
71
+ private
72
+
73
+ def send_request method, path='/', params={}, host= UserMgmt.external_database_URI
74
+ path = path.to_s.downcase
75
+ path = '/' << path unless path.start_with? '/'
76
+ uri = URI.parse(host)
77
+ http = Net::HTTP.new(uri.host, uri.port)
78
+
79
+ case method.to_s.downcase
80
+ when 'get'
81
+ request = Net::HTTP::Get.new(uri.request_uri << path, initheader = {'Content-Type' =>'application/json'})
82
+ when 'post'
83
+ request = Net::HTTP::Post.new(uri.request_uri << path, initheader = {'Content-Type' =>'application/json'})
84
+ when 'put'
85
+ request = Net::HTTP::Put.new(uri.request_uri << path, initheader = {'Content-Type' =>'application/json'})
86
+ when 'delete'
87
+ request = Net::HTTP::Delete.new(uri.request_uri << path, initheader = {'Content-Type' =>'application/json'})
88
+ end
89
+
90
+ request.body = params.to_json
91
+ response = http.request(request)
92
+ begin
93
+ return { body: JSON.parse(response.body), status: response.code }
94
+ rescue
95
+ return { body: response.body, status: response.code }
96
+ end
97
+ end
98
+
99
+
3
100
  end
4
101
  end
@@ -0,0 +1,32 @@
1
+ require_dependency "user_mgmt/application_controller"
2
+
3
+ module UserMgmt
4
+ class RegistrationsController < ApplicationController
5
+
6
+ # GET /user/sign_up
7
+ def new
8
+
9
+ end
10
+
11
+ # POST /user
12
+ def create
13
+
14
+ response = sign_up *params[:user].values
15
+
16
+ if response[:status] == "200"
17
+ flash[:notice] = "User was created succesfully!"
18
+ redirect_to main_app.root_path
19
+ else
20
+ flash[:warning] = response[:body]#"User couldn't be created. Try again."
21
+ redirect_to sign_up_path
22
+ end
23
+
24
+ end
25
+
26
+ # GET /user/edit
27
+ def edit
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,81 @@
1
+ require_dependency "user_mgmt/application_controller"
2
+
3
+ module UserMgmt
4
+ class SessionsController < ApplicationController
5
+
6
+ # GET /user/log_in
7
+ def new
8
+
9
+ end
10
+
11
+ # POST /user/log_in
12
+ def create
13
+
14
+ response = log_in *params[:user].values
15
+
16
+ if response[:status] == "200"
17
+ flash[:notice] = "User logged in!"
18
+ session[:user_session_id] = response[:body]["session"]
19
+ redirect_to main_app.root_path
20
+ else
21
+ flash[:warning] = response[:body]
22
+ redirect_to log_in_path
23
+ end
24
+
25
+ end
26
+
27
+ # GET 'auth/:provider/callback'
28
+ # That is the controller method that is called after getting the information from an oauth strategy
29
+ def oauth_email
30
+
31
+ @uid = env['omniauth.auth']["uid"]
32
+ @provider= env['omniauth.auth']["provider"]
33
+
34
+ if @provider == "google_oauth2"
35
+ @provider = "google"
36
+ end
37
+
38
+ if @provider == "windowslive"
39
+ @provider = "windows_live"
40
+ end
41
+
42
+ response = log_in_oauth @uid, @provider
43
+
44
+ # if user logged in succesfully, just redirect to main page,
45
+ # otherwise it means the user doesn't exist yet, so continue
46
+ # normaly (user will be asked for his email).
47
+ if response[:status] == "200"
48
+ session[:user_session_id] = response[:body]["session"]
49
+ redirect_to main_app.root_path, notice: "User logged in!"
50
+ end
51
+
52
+ end
53
+
54
+ # POST '/oauth_log_in'
55
+ def create_oauth
56
+
57
+ response = sign_up_oauth params["uid"], params["provider"].to_sym, params["user"]["Email"]
58
+
59
+ #if for some reason, the user couldn't be created
60
+ if response[:status] == "400"
61
+ redirect_to sign_up_path, notice: response[:body]
62
+ end
63
+
64
+ response = log_in_oauth params["uid"], params["provider"].to_sym
65
+
66
+ session[:user_session_id] = response[:body]["session"]
67
+
68
+ redirect_to main_app.root_path, notice: "User logged in!"
69
+
70
+ end
71
+
72
+ # GET /user/log_out
73
+ def destroy
74
+
75
+ session[:user_session_id] = nil
76
+ redirect_to main_app.root_path, notice: "Logged out!"
77
+
78
+ end
79
+
80
+ end
81
+ end
@@ -1,4 +1,9 @@
1
1
  module UserMgmt
2
2
  module ApplicationHelper
3
+
4
+ def user_logged_in
5
+ session[:user_session_id] != nil
6
+ end
7
+
3
8
  end
4
9
  end
@@ -0,0 +1,4 @@
1
+ module UserMgmt
2
+ module RegistrationsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module UserMgmt
2
+ module SessionsHelper
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ module UserMgmt
2
+ class User
3
+
4
+ attr_accessor :email, :password, :password_confirmation
5
+
6
+ def self.find session_id
7
+
8
+ end
9
+
10
+ def self.dummy
11
+ "yay"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+
5
+ %title UserMgmt
6
+ = stylesheet_link_tag "user_mgmt/application", media: "all"
7
+ = javascript_include_tag "user_mgmt/application"
8
+ = csrf_meta_tags
9
+
10
+ %body
11
+ #main
12
+ - if flash[:notice]
13
+ #notice.message= flash[:notice]
14
+ - elsif flash[:warning]
15
+ #warning.message= flash[:warning]
16
+
17
+ = yield
@@ -6,13 +6,10 @@
6
6
  / %li= error
7
7
 
8
8
  %div
9
- = label :user, :email, 'Email'
10
- = text_field :user, 'Email'
9
+ = text_field :user, 'Email', :class => "input-block-level", :placeholder => 'Email'
11
10
 
12
11
  %div
13
- = label :user, :password, 'Password'
14
- = text_field :user, 'Password'
12
+ = text_field :user, 'Password', :class => "input-block-level", :type => "password", :placeholder => 'Password'
15
13
 
16
14
  %div
17
- = label :user, :password_confirmation, 'Password Confirmation'
18
- = text_field :user, 'Password Confirmation'
15
+ = text_field :user, 'Password Confirmation', :class => "input-block-level", :type => "password", :placeholder => 'Password Confirmation'
@@ -0,0 +1,5 @@
1
+ .container
2
+ = form_tag main_app.root_path, :class => "form-signin", :method => :get do
3
+ %h2 Edit
4
+ = render :partial => 'user_form'
5
+ = submit_tag 'submit', :class => "btn btn-large btn-primary"
@@ -1,6 +1,18 @@
1
- %h2 Sign up
2
- = form_tag @@external_database_URI, :method => :post do
3
- = render :partial => 'user_form'
4
- = submit_tag 'submit'
5
-
6
- /a{}
1
+ .container
2
+ = form_tag user_path, :class => "form-signin", :method => :post do
3
+ %h2 Sign up
4
+ = render :partial => 'user_form'
5
+ = submit_tag 'submit', :class => "btn btn-large btn-primary"
6
+ %ul.unstyled
7
+ %li
8
+ = link_to "Log in with Facebook", "auth/facebook"
9
+ %li
10
+ = link_to "Log in with Twitter", "auth/twitter"
11
+ %li
12
+ = link_to "Log in with Outlook", "auth/windowslive"
13
+ %li
14
+ = link_to "Log in with LinkedIn", "auth/linkedin"
15
+ %li
16
+ = link_to "Log in with Yahoo", "auth/yahoo"
17
+ %li
18
+ = link_to "Log in with GMail", "auth/google_oauth2"
@@ -0,0 +1,30 @@
1
+ .container
2
+ = form_tag user_log_in_path, :class => "form-signin", :method => :post do
3
+ %h2.form-signin-heading Log in
4
+
5
+ %div
6
+ = text_field :user, 'Email', :class => "input-block-level", :placeholder => "Email"
7
+
8
+ %div
9
+ = text_field :user, 'Password', :class => "input-block-level", :type => "password", :placeholder => 'Password'
10
+
11
+ = submit_tag 'submit', :class => "btn btn-large btn-primary"
12
+
13
+ %ul.unstyled
14
+ %li
15
+
16
+ = link_to "Log in with Facebook", "auth/facebook"
17
+ %li
18
+ = link_to "Log in with Twitter", "auth/twitter"
19
+ %li
20
+ = link_to "Log in with Outlook", "auth/windowslive"
21
+ %li
22
+ = link_to "Log in with LinkedIn", "auth/linkedin"
23
+ %li
24
+ = link_to "Log in with Yahoo", "auth/yahoo"
25
+ %li
26
+ = link_to "Log in with GMail", "auth/google_oauth2"
27
+
28
+
29
+
30
+
@@ -0,0 +1,11 @@
1
+ .container
2
+
3
+ = form_tag oauth_log_in_path(:uid => @uid, :provider => @provider), :class => "form-signin", :method => :post do
4
+ %h2.form-signin-heading Sign up
5
+
6
+ %h4 Tell us your email address please:
7
+
8
+ %div
9
+ = text_field :user, 'Email', :class => "input-block-level", :placeholder => "Email"
10
+
11
+ = submit_tag 'submit', :class => "btn btn-large btn-primary"
data/config/routes.rb CHANGED
@@ -1,2 +1,16 @@
1
1
  UserMgmt::Engine.routes.draw do
2
- end
2
+
3
+ get '/log_in' => "sessions#new", as: 'log_in'
4
+ post '/log_in' => "sessions#create", as: 'user_log_in'
5
+ get '/log_out' => "sessions#destroy", as: 'log_out'
6
+ post '/oauth_log_in' => "sessions#create_oauth", as: 'oauth_log_in'
7
+
8
+ get '/sign_up' => 'registrations#new', as: 'sign_up'
9
+ get '/edit' => 'registrations#edit', as: 'edit'
10
+ post '/' => 'registrations#create', as: 'user'
11
+
12
+ get 'auth/:provider/callback' => 'sessions#oauth_email', as: 'oauth_email'
13
+ get 'auth/failure' => 'application#main_page'
14
+
15
+
16
+ end
@@ -3,8 +3,24 @@
3
3
  Some setup you must do manually if you haven't yet:
4
4
 
5
5
  1. Ensure you have defined your external database URI, in
6
- config/initializers/user_mgmt.rb:
6
+ config/initializers/user_mgmt.rb.
7
+ For example:
7
8
 
8
- config.external_database_URI = "yourexternaldatabaseuri.com"
9
+ config.external_database_URI = "http://localhost:3000/"
10
+
11
+ 2. Ensure you have defined root_url to *something* in your config/routes.rb.
12
+ For example:
13
+
14
+ root :to => "home#index"
15
+
16
+ 3. Ensure you have flash messages in app/views/layouts/application.html.haml.
17
+ For example:
18
+
19
+ %body
20
+ #main
21
+ - if flash[:notice]
22
+ #notice.message= flash[:notice]
23
+ - elsif flash[:warning]
24
+ #warning.message= flash[:warning]
9
25
 
10
26
  ===============================================================================
@@ -4,6 +4,33 @@ UserMgmt.setup do |config|
4
4
 
5
5
  # Ensure you defined default external database URI, otherwise
6
6
  # authentication won't be possible to happen
7
- config.external_database_URI = "yourexternaldatabaseuri.com"
7
+ config.external_database_URI = "http://localhost:3000/"
8
8
 
9
9
  end
10
+
11
+ # Edit your strategy keys:
12
+
13
+ ENV['TWITTER_KEY'] = ""
14
+ ENV['TWITTER_SECRET'] = ""
15
+
16
+ ENV['FACEBOOK_KEY'] = ""
17
+ ENV['FACEBOOK_SECRET'] = ""
18
+
19
+ ENV['LINKEDIN_KEY'] = ""
20
+ ENV['LINKEDIN_SECRET'] = ""
21
+
22
+ ENV['WINDOWSLIVE_KEY'] = ""
23
+ ENV['WINDOWSLIVE_SECRET'] = ""
24
+
25
+ ENV['YAHOO_KEY'] = ""
26
+ ENV['YAHOO_SECRET'] = ""
27
+
28
+ ENV['GOOGLE_KEY'] = ""
29
+ ENV['GOOGLE_SECRET'] = ""
30
+
31
+ # The code below include the view helpers from user_mgmt in the main app.
32
+ # NOTE: Do not change this code.
33
+ ActiveSupport.on_load :action_controller do
34
+ helper UserMgmt::ApplicationHelper
35
+ end
36
+
@@ -14,9 +14,15 @@ module UserMgmt
14
14
  # copy_file "../../../config/locales/en.yml", "config/locales/user_mgmt.en.yml"
15
15
  # end
16
16
 
17
+ def add_user_mgmt_routes
18
+ user_mgmt_route = "mount UserMgmt::Engine => '/user'"
19
+ route user_mgmt_route
20
+ end
21
+
17
22
  def show_readme
18
23
  readme "README" if behavior == :invoke
19
24
  end
25
+
20
26
  end
21
27
  end
22
28
  end