stormpath-rails 1.1.2.beta → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/.rubocop.yml +22 -0
  5. data/.travis.yml +6 -3
  6. data/Gemfile +10 -3
  7. data/README.md +139 -142
  8. data/Rakefile +9 -9
  9. data/app/assets/stylesheets/stormpath.css.scss +3 -2
  10. data/app/controllers/stormpath/rails/base_controller.rb +25 -6
  11. data/app/controllers/stormpath/rails/change_password/create_controller.rb +68 -0
  12. data/app/controllers/stormpath/rails/change_password/new_controller.rb +38 -0
  13. data/app/controllers/stormpath/rails/forgot_password/create_controller.rb +37 -0
  14. data/app/controllers/stormpath/rails/forgot_password/new_controller.rb +14 -0
  15. data/app/controllers/stormpath/rails/login/create_controller.rb +60 -0
  16. data/app/controllers/stormpath/rails/login/new_controller.rb +20 -0
  17. data/app/controllers/stormpath/rails/logout/create_controller.rb +61 -0
  18. data/app/controllers/stormpath/rails/oauth2/create_controller.rb +82 -0
  19. data/app/controllers/stormpath/rails/oauth2/new_controller.rb +11 -0
  20. data/app/controllers/stormpath/rails/profile/show_controller.rb +15 -0
  21. data/app/controllers/stormpath/rails/register/create_controller.rb +86 -0
  22. data/app/controllers/stormpath/rails/register/new_controller.rb +20 -0
  23. data/app/controllers/stormpath/rails/verify_email/create_controller.rb +37 -0
  24. data/app/controllers/stormpath/rails/verify_email/show_controller.rb +51 -0
  25. data/app/forms/stormpath/rails/login_form.rb +60 -0
  26. data/app/forms/stormpath/rails/registration_form.rb +106 -0
  27. data/app/forms/stormpath/rails/registration_form_fields.rb +71 -0
  28. data/app/helpers/social_helper.rb +2 -1
  29. data/app/serializers/stormpath/rails/account_serializer.rb +32 -0
  30. data/app/serializers/stormpath/rails/form_serializer.rb +37 -0
  31. data/app/serializers/stormpath/rails/login_new_serializer.rb +11 -0
  32. data/app/serializers/stormpath/rails/profile_serializer.rb +71 -0
  33. data/app/serializers/stormpath/rails/registration_form_serializer.rb +11 -0
  34. data/app/services/stormpath/rails/account_from_access_token/local_account_resolution.rb +48 -0
  35. data/app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb +27 -0
  36. data/app/services/stormpath/rails/account_from_access_token.rb +33 -0
  37. data/app/services/stormpath/rails/account_login.rb +28 -0
  38. data/app/services/stormpath/rails/account_login_with_stormpath_token.rb +32 -0
  39. data/app/services/stormpath/rails/client_credentials_authentication.rb +40 -0
  40. data/app/services/stormpath/rails/controller_authentication/from_basic_auth.rb +45 -0
  41. data/app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb +34 -0
  42. data/app/services/stormpath/rails/controller_authentication/from_cookies.rb +71 -0
  43. data/app/services/stormpath/rails/controller_authentication.rb +44 -0
  44. data/app/services/stormpath/rails/delete_access_token.rb +48 -0
  45. data/app/services/stormpath/rails/delete_refresh_token.rb +11 -0
  46. data/app/services/stormpath/rails/forgot_password_token_verification.rb +31 -0
  47. data/app/services/stormpath/rails/password_change.rb +17 -0
  48. data/app/services/stormpath/rails/refresh_token_authentication.rb +28 -0
  49. data/app/services/stormpath/rails/resend_email_verification.rb +33 -0
  50. data/app/services/stormpath/rails/send_password_reset_email.rb +33 -0
  51. data/app/services/stormpath/rails/token_cookie_setter.rb +84 -0
  52. data/app/services/stormpath/rails/verify_email_token.rb +27 -0
  53. data/app/views/{passwords/forgot_change.html.erb → stormpath/rails/change_password/new.html.erb} +4 -10
  54. data/app/views/{passwords/forgot.html.erb → stormpath/rails/forgot_password/new.html.erb} +14 -4
  55. data/app/views/{layouts → stormpath/rails/layouts}/stormpath.html.erb +3 -3
  56. data/app/views/stormpath/rails/login/_form.html.erb +45 -0
  57. data/app/views/stormpath/rails/login/new.html.erb +12 -0
  58. data/app/views/stormpath/rails/register/_form.html.erb +19 -0
  59. data/app/views/{users → stormpath/rails/register}/new.html.erb +3 -3
  60. data/app/views/stormpath/rails/shared/_input.html.erb +15 -0
  61. data/app/views/stormpath/rails/verify_email/new.html.erb +49 -0
  62. data/bin/console +3 -3
  63. data/bin/rails +1 -1
  64. data/bin/rake +2 -2
  65. data/bin/rspec +2 -2
  66. data/config/initializers/assets.rb +3 -1
  67. data/lib/generators/stormpath/install/install_generator.rb +1 -92
  68. data/lib/generators/stormpath/install/templates/default_config.yml +229 -0
  69. data/lib/generators/stormpath/views/USAGE +0 -0
  70. data/lib/generators/stormpath/views/views_generator.rb +2 -2
  71. data/lib/stormpath/rails/client.rb +8 -85
  72. data/lib/stormpath/rails/config/account_store_verification.rb +45 -0
  73. data/lib/stormpath/rails/config/application_resolution.rb +76 -0
  74. data/lib/stormpath/rails/config/dynamic_configuration.rb +50 -0
  75. data/lib/stormpath/rails/config/read_file.rb +35 -0
  76. data/lib/stormpath/rails/configuration.rb +30 -35
  77. data/lib/stormpath/rails/content_type_negotiator.rb +50 -0
  78. data/lib/stormpath/rails/controller.rb +36 -5
  79. data/lib/stormpath/rails/errors/invalid_sptoken_error.rb +9 -0
  80. data/lib/stormpath/rails/errors/no_sptoken_error.rb +13 -0
  81. data/lib/stormpath/rails/router.rb +75 -0
  82. data/lib/stormpath/rails/routing_constraint.rb +9 -0
  83. data/lib/stormpath/rails/social.rb +6 -6
  84. data/lib/stormpath/rails/version.rb +2 -1
  85. data/lib/stormpath/rails.rb +9 -19
  86. data/lib/stormpath-rails.rb +1 -0
  87. data/stormpath-rails.gemspec +13 -11
  88. metadata +96 -54
  89. data/app/controllers/stormpath/rails/omniauth_controller.rb +0 -11
  90. data/app/controllers/stormpath/rails/passwords_controller.rb +0 -56
  91. data/app/controllers/stormpath/rails/sessions_controller.rb +0 -52
  92. data/app/controllers/stormpath/rails/users_controller.rb +0 -65
  93. data/app/views/passwords/edit.html.erb +0 -0
  94. data/app/views/passwords/email_sent.html.erb +0 -15
  95. data/app/views/passwords/forgot_change_failed.html.erb +0 -14
  96. data/app/views/passwords/forgot_complete.html.erb +0 -19
  97. data/app/views/sessions/_facebook_login_form.erb +0 -31
  98. data/app/views/sessions/_form.html.erb +0 -31
  99. data/app/views/sessions/_google_login_form.html.erb +0 -3
  100. data/app/views/sessions/_social_auth.html.erb +0 -7
  101. data/app/views/sessions/new.html.erb +0 -21
  102. data/app/views/users/_form.html.erb +0 -43
  103. data/app/views/users/verification_complete.html.erb +0 -20
  104. data/app/views/users/verification_email_sent.html.erb +0 -15
  105. data/app/views/users/verification_failed.html.erb +0 -14
  106. data/app/views/users/verification_resend.html.erb +0 -14
  107. data/config/routes.rb +0 -16
  108. data/lib/generators/stormpath/install/templates/db/migrate/add_stormpath_to_users.rb +0 -21
  109. data/lib/generators/stormpath/install/templates/db/migrate/create_users.rb +0 -12
  110. data/lib/generators/stormpath/install/templates/stormpath.rb +0 -4
  111. data/lib/generators/stormpath/install/templates/user.rb +0 -3
  112. data/lib/generators/stormpath/routes/routes_generator.rb +0 -23
  113. data/lib/generators/stormpath/routes/templates/routes.rb +0 -5
  114. data/lib/stormpath/rails/account.rb +0 -6
  115. data/lib/stormpath/rails/account_status.rb +0 -28
  116. data/lib/stormpath/rails/authentication.rb +0 -72
  117. data/lib/stormpath/rails/authentication_status.rb +0 -22
  118. data/lib/stormpath/rails/session.rb +0 -37
  119. data/lib/stormpath/rails/user.rb +0 -25
  120. data/lib/stormpath/rails/user_config/api_key.rb +0 -17
  121. data/lib/stormpath/rails/user_config/application.rb +0 -12
  122. data/lib/stormpath/rails/user_config/facebook.rb +0 -16
  123. data/lib/stormpath/rails/user_config/forgot_password.rb +0 -12
  124. data/lib/stormpath/rails/user_config/google.rb +0 -16
  125. data/lib/stormpath/rails/user_config/id_site.rb +0 -13
  126. data/lib/stormpath/rails/user_config/login.rb +0 -13
  127. data/lib/stormpath/rails/user_config/logout.rb +0 -13
  128. data/lib/stormpath/rails/user_config/register.rb +0 -13
  129. data/lib/stormpath/rails/user_config/verify_email.rb +0 -14
  130. data/lib/stormpath/testing/helpers.rb +0 -49
@@ -1,11 +0,0 @@
1
- class Stormpath::Rails::OmniauthController < Stormpath::Rails::BaseController
2
- def create
3
- result = create_omniauth_user('facebook', params[:access_token])
4
- user = find_or_create_user_from_account(result.account)
5
-
6
- initialize_session user
7
- set_flash_message :notice, "Successfully signed in"
8
-
9
- redirect_to root_path
10
- end
11
- end
@@ -1,56 +0,0 @@
1
- class Stormpath::Rails::PasswordsController < Stormpath::Rails::BaseController
2
- before_filter :redirect_password_reset_disabled, only: :forgot
3
-
4
- def forgot_send
5
- result = reset_password(params[:password][:email])
6
-
7
- if result.success?
8
- render template: 'passwords/email_sent'
9
- else
10
- set_flash_message :error, "Invalid email address."
11
- render template: 'passwords/forgot'
12
- end
13
- end
14
-
15
- def forgot
16
- render template: 'passwords/forgot'
17
- end
18
-
19
- def forgot_change
20
- result = verify_email_token params[:sptoken]
21
-
22
- if result.success?
23
- @account_url = result.account_url
24
- render template: "passwords/forgot_change"
25
- else
26
- render template: "passwords/forgot_change_failed"
27
- end
28
- end
29
-
30
- def forgot_update
31
- @account_url = params[:account_url]
32
- if passwords_match?
33
- result = update_password(params[:account_url], params[:password][:original])
34
- if result.success?
35
- render template: "passwords/forgot_complete"
36
- else
37
- set_flash_message :error, result.error_message
38
- render template: "passwords/forgot_change"
39
- end
40
-
41
- else
42
- set_flash_message :error, 'Passwords do not match.'
43
- render template: "passwords/forgot_change"
44
- end
45
- end
46
-
47
- private
48
-
49
- def passwords_match?
50
- params[:password][:original] == params[:password][:repeated]
51
- end
52
-
53
- def redirect_password_reset_disabled
54
- redirect_to root_path unless configuration.forgot_password.enabled
55
- end
56
- end
@@ -1,52 +0,0 @@
1
- class Stormpath::Rails::SessionsController < Stormpath::Rails::BaseController
2
- before_filter :redirect_signed_in_users, only: :new
3
-
4
- def create
5
- result = authenticate user_from_params
6
-
7
- if result.success?
8
- @user = find_user_by_email params[:session][:email]
9
- initialize_session(@user)
10
-
11
- redirect_to configuration.login.next_uri, notice: 'Successfully signed in'
12
- else
13
- set_flash_message :error, result.error_message
14
- render template: "sessions/new"
15
- end
16
- end
17
-
18
- def destroy
19
- logout
20
- set_flash_message :notice, 'You have been logged out successfully.'
21
- redirect_to configuration.logout.next_uri
22
- end
23
-
24
- def new
25
- if configuration.id_site.enabled?
26
- redirect_to id_site_login_url
27
- else
28
- render template: "sessions/new"
29
- end
30
- end
31
-
32
- def redirect
33
- user_data = handle_id_site_callback(request.url)
34
- @user = find_user_by_email user_data.email
35
- initialize_session(@user)
36
-
37
- redirect_to configuration.id_site.next_uri, notice: 'Successfully signed in'
38
- end
39
-
40
- private
41
-
42
- def user_from_params
43
- ::User.new.tap do |user|
44
- user.email = params[:session][:email]
45
- user.password = params[:session][:password]
46
- end
47
- end
48
-
49
- def redirect_signed_in_users
50
- redirect_to root_path if signed_in?
51
- end
52
- end
@@ -1,65 +0,0 @@
1
- class Stormpath::Rails::UsersController < Stormpath::Rails::BaseController
2
- def create
3
- @user = user_from_params
4
- result = create_stormpath_account @user
5
-
6
- if result.success?
7
- @user.save
8
-
9
- if configuration.verify_email.enabled?
10
- render template: "users/verification_email_sent"
11
- else
12
- initialize_session(@user)
13
- set_flash_message :notice, 'Your account was created successfully'
14
- redirect_to configuration.register.next_uri
15
- end
16
- else
17
- set_flash_message :error, result.error_message
18
- render template: "users/new"
19
- end
20
- end
21
-
22
- def new
23
- if configuration.id_site.enabled?
24
- redirect_to id_site_register_url
25
- else
26
- if signed_in?
27
- redirect_to root_path
28
- else
29
- @user = user_from_params
30
- render template: "users/new"
31
- end
32
- end
33
- end
34
-
35
- def verify
36
- result = verify_email_token params[:sptoken]
37
-
38
- if result.success?
39
- @account_url = result.account_url
40
- render template: "users/verification_complete"
41
- else
42
- render template: "users/verification_failed"
43
- end
44
- end
45
-
46
- private
47
-
48
- def user_from_params
49
- email = user_params.delete(:email)
50
- password = user_params.delete(:password)
51
- given_name = user_params.delete(:given_name)
52
- surname = user_params.delete(:surname)
53
-
54
- ::User.new.tap do |user|
55
- user.email = email
56
- user.password = password
57
- user.given_name = given_name
58
- user.surname = surname
59
- end
60
- end
61
-
62
- def user_params
63
- params[:user] || Hash.new
64
- end
65
- end
File without changes
@@ -1,15 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Your password reset email has been sent!</span>
8
- <p>We have sent a password reset email to the email address you have provided.</p>
9
- <p>Please check your inbox to continue.</p>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
15
- </div>
@@ -1,14 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Password Reset Failed</span>
8
- <p>Your password reset attempt has failed. This might happen for several reasons: your reset token might be expired, it might have already been used, or we may just be having issues right now! Please try again, and if you're still having problems, contact the site administrator for help!</p>
9
- </div>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
@@ -1,19 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Password Change Complete!</span>
8
- <p>Your password has been changed, and you have been logged into your account. You will be redirected back to the site in 5 seconds.</p>
9
- </div>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
15
-
16
- <script type="text/javascript">
17
- var delay = 5000;
18
- setTimeout(function(){ window.location = "<%= sign_in_path %>"; }, delay);
19
- </script>
@@ -1,31 +0,0 @@
1
- <%= button_tag "Facebook", class: "btn btn-social btn-facebook", "onclick" => "facebookLogin()" %>
2
-
3
- <script type="text/javascript">
4
- function facebookLogin() {
5
- var FB = window.FB;
6
-
7
- FB.login(function(response) {
8
- console.log(response);
9
-
10
- if (response.status === 'connected') {
11
- window.location.replace("<%= omniauth_login_path %>" + '?access_token=' + response.authResponse.accessToken);
12
- }
13
- });
14
- }
15
-
16
- window.fbAsyncInit = function() {
17
- FB.init({
18
- appId : <%= facebook_app_id %>,
19
- xfbml : true,
20
- version : 'v2.4'
21
- });
22
- };
23
-
24
- (function(d, s, id){
25
- var js, fjs = d.getElementsByTagName(s)[0];
26
- if (d.getElementById(id)) {return;}
27
- js = d.createElement(s); js.id = id;
28
- js.src = "//connect.facebook.net/en_US/sdk.js";
29
- fjs.parentNode.insertBefore(js, fjs);
30
- }(document, 'script', 'facebook-jssdk'));
31
- </script>
@@ -1,31 +0,0 @@
1
- <div class="email-password-area col-xs-12 <%= box_class %>">
2
- <div class="header">
3
- <span>Log in or <%= link_to "Create Account", sign_up_path %></span>
4
- </div>
5
-
6
- <% if flash[:error] %>
7
- <div class="alert alert-danger bad-login">
8
- <p><%= flash[:error] %></p>
9
- </div>
10
- <% end %>
11
-
12
- <%= form_for :session, url: session_path, html: {class: "login-form form-horizontal"} do |form| %>
13
- <div class="form-group group-email">
14
- <%= form.label :email, class: label_class %>
15
- <div class="<%= input_class %>">
16
- <%= form.text_field :email, type: 'text', placeholder: 'Email', class: "form-control", id: "session-email" %>
17
- </div>
18
- </div>
19
-
20
- <div class="form-group group-password">
21
- <%= form.label :password, class: label_class %>
22
- <div class="<%= input_class %>">
23
- <%= form.password_field :password, type: 'password', placeholder: 'Password', class: "form-control" %>
24
- </div>
25
- </div>
26
-
27
- <div>
28
- <%= button_tag "Log in", :class => "login btn btn-login btn-sp-green", :type => "submit" %>
29
- </div>
30
- <% end %>
31
- </div>
@@ -1,3 +0,0 @@
1
- <%= button_tag "Google", class: "btn btn-social btn-google", "onclick" => "facebookLogin()" %>
2
-
3
-
@@ -1,7 +0,0 @@
1
- <% if facebook_login_enabled? %>
2
- <%= render partial: '/sessions/facebook_login_form' %>
3
- <% end %>
4
-
5
- <% if google_login_enabled? %>
6
- <%= render partial: '/sessions/google_login_form' %>
7
- <% end %>
@@ -1,21 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <%= render partial: '/sessions/form' %>
6
- <% if social_auth? %>
7
- <div class="social-area col-xs-12 col-sm-4">
8
- <div class="header">
9
- &nbsp;
10
- </div>
11
- <label>Easy 1-click login:</label>
12
- <%= render partial: '/sessions/social_auth' %>
13
- </div>
14
- <% end %>
15
- </div>
16
- <% if Stormpath::Rails.config.forgot_password.enabled %>
17
- <%= link_to "Forgot Password?", forgot_path, class: "forgot" %>
18
- <% end %>
19
- </div>
20
- </div>
21
- </div>
@@ -1,43 +0,0 @@
1
- <div class="col-sm-12">
2
- <div class="header">
3
- <span>Create Account</span>
4
- </div>
5
-
6
- <% if flash[:error] %>
7
- <div class="alert alert-danger">
8
- <p><%= flash[:error] %></p>
9
- </div>
10
- <% end %>
11
-
12
- <%= form_for @user, html: { class: "registration-form form-horizontal sp-form" } do |form| %>
13
- <div form-group="true" class="form-group group-first-name">
14
- <%= form.label :given_name, "First Name", class: "col-sm-4" %>
15
- <div class="col-sm-8">
16
- <%= form.text_field :given_name, placeholder: "First Name", class: "form-control" %>
17
- </div>
18
- </div>
19
-
20
- <div form-group="true" class="form-group group-first-name">
21
- <%= form.label :surname, "Last Name", class: "col-sm-4" %>
22
- <div class="col-sm-8">
23
- <%= form.text_field :surname, placeholder: "Last Name", class: "form-control" %>
24
- </div>
25
- </div>
26
-
27
- <div form-group="true" class="form-group group-first-name">
28
- <%= form.label :email, "Email", class: "col-sm-4" %>
29
- <div class="col-sm-8">
30
- <%= form.text_field :email, placeholder: "Email", class: "form-control" %>
31
- </div>
32
- </div>
33
-
34
- <div form-group="true" class="form-group group-first-name">
35
- <%= form.label :password, "Password", class: "col-sm-4" %>
36
- <div class="col-sm-8">
37
- <%= form.password_field :password, placeholder: "Password", class: "form-control" %>
38
- </div>
39
- </div>
40
-
41
- <%= button_tag "Create Account", :class => "btn btn-register btn-sp-green", :type => "submit" %>
42
- <% end %>
43
- </div>
@@ -1,20 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Account Verification Complete!</span>
8
- <p>Before you can log into your account, you need to activate your account by clicking the link we sent to you at your email address.</p>
9
- <p>Your account has been verified, and you have been logged into your account. You will be redirected back to the site in 5 seconds.</p>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
15
- </div>
16
-
17
- <script type="text/javascript">
18
- var delay = 5000;
19
- setTimeout(function(){ window.location = "<%= root_path %>"; }, delay);
20
- </script>
@@ -1,15 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Your account verification email has been sent!</span>
8
- <p>Before you can log into your account, you need to activate your account by clicking the link we sent to you at your email address.</p>
9
- <p>Please check your inbox to continue.</p>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
15
- </div>
@@ -1,14 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Verification Failed</span>
8
- <p>Your account verification has failed. This might happen for several reasons: your verification token might be expired, it might have already been used, or we may just be having issues right now! Please try again, and if you're still having problems, contact the site administrator for help!</p>
9
- </div>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
@@ -1,14 +0,0 @@
1
- <div class="container custom-container">
2
- <div class="va-wrapper">
3
- <div class="view login-view container">
4
- <div class="box row">
5
- <div class="email-password-area col-xs-12 large col-sm-12">
6
- <div class="header">
7
- <span>Didn't receive your account verification email?</span>
8
- <p>Enter your email address below and we'll resend your account verification email. You will be sent an email which you will need to open to continue. You may need to check your spam folder.</p>
9
- </div>
10
- </div>
11
- </div>
12
- </div>
13
- </div>
14
- </div>
data/config/routes.rb DELETED
@@ -1,16 +0,0 @@
1
- Rails.application.routes.draw do
2
- resource :session, controller: 'stormpath/rails/sessions', only: [:create]
3
- resource :users, controller: 'stormpath/rails/users', only: :create
4
- get Stormpath::Rails.config.register.uri => 'stormpath/rails/users#new', as: 'sign_up'
5
- get '/verify' => 'stormpath/rails/users#verify', as: 'verify'
6
-
7
- get Stormpath::Rails.config.login.uri => 'stormpath/rails/sessions#new', as: 'sign_in'
8
- delete Stormpath::Rails.config.logout.uri => 'stormpath/rails/sessions#destroy', as: 'sign_out'
9
- get Stormpath::Rails.config.id_site.uri => 'stormpath/rails/sessions#redirect', as: 'redirect'
10
- get '/omniauth_login' => 'stormpath/rails/omniauth#create', as: 'omniauth_login'
11
-
12
- get Stormpath::Rails.config.forgot_password.uri => 'stormpath/rails/passwords#forgot', as: 'forgot'
13
- post Stormpath::Rails.config.forgot_password.uri => 'stormpath/rails/passwords#forgot_send', as: 'forgot_send'
14
- get '/forgot/change' => 'stormpath/rails/passwords#forgot_change', as: 'forgot_change'
15
- post '/forgot/change/:account_url' => 'stormpath/rails/passwords#forgot_update', as: 'forgot_update'
16
- end
@@ -1,21 +0,0 @@
1
- class AddStormpathToUsers < ActiveRecord::Migration
2
- def self.up
3
- change_table :users do |t|
4
- <% config[:new_columns].values.each do |column| -%>
5
- <%= column %>
6
- <% end -%>
7
- end
8
-
9
- <% config[:new_indexes].values.each do |index| -%>
10
- <%= index %>
11
- <% end -%>
12
- end
13
-
14
- def self.down
15
- change_table :users do |t|
16
- <% if config[:new_columns].any? -%>
17
- t.remove <%= new_columns.keys.map { |column| ":#{column}" }.join(",") %>
18
- <% end -%>
19
- end
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.timestamps null: false
5
- t.string :email, null: false
6
- t.string :given_name, null: false
7
- t.string :surname, null: false
8
- end
9
-
10
- add_index :users, :email
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- Stormpath::Rails.configure do |config|
2
- config.api_key.file = ENV['STORMPATH_API_KEY_FILE_LOCATION']
3
- config.application.href = ENV['STORMPATH_SDK_TEST_APPLICATION_URL']
4
- end
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include Stormpath::Rails::User
3
- end
@@ -1,23 +0,0 @@
1
- require 'rails/generators/base'
2
-
3
- module Stormpath
4
- module Generators
5
- class RoutesGenerator < ::Rails::Generators::Base
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def inject_stormpath_routes_into_application_routes
9
- route(stormpath_routes)
10
- end
11
-
12
- private
13
-
14
- def stormpath_routes
15
- File.read(routes_file_path)
16
- end
17
-
18
- def routes_file_path
19
- File.expand_path(find_in_source_paths('routes.rb'))
20
- end
21
- end
22
- end
23
- end
@@ -1,5 +0,0 @@
1
- resource :session, controller: 'stormpath/sessions', only: [:create]
2
- resource :users, controller: 'stormpath/users', only: :create
3
- get '/register' => 'stormpath/users#new', as: 'sign_up'
4
- get '/login' => 'stormpath/sessions#new', as: 'sign_in'
5
- delete '/sign_out' => 'stormpath/sessions#destroy', as: 'sign_out'
@@ -1,6 +0,0 @@
1
- module Stormpath
2
- module Rails
3
- class Account
4
- end
5
- end
6
- end
@@ -1,28 +0,0 @@
1
- module Stormpath
2
- module Rails
3
- class AccountStatus
4
- attr_accessor :response
5
-
6
- def initialize(response)
7
- @response = response
8
- end
9
-
10
- def success?
11
- @response.instance_of? Stormpath::Resource::Account
12
- end
13
-
14
- def error_message
15
- if @response.instance_of? String
16
- return @response
17
- else
18
- ''
19
- end
20
- end
21
-
22
- def account_url
23
- return '' unless success?
24
- @response.href.split('/').last
25
- end
26
- end
27
- end
28
- end
@@ -1,72 +0,0 @@
1
- module Stormpath
2
- module Rails
3
- module Authentication
4
- private
5
-
6
- def create_stormpath_account(user)
7
- Client.create_stormpath_account(user)
8
- end
9
-
10
- def authenticate(user)
11
- Client.authenticate(user)
12
- end
13
-
14
- def reset_password(email)
15
- Client.reset_password(email)
16
- end
17
-
18
- def verify_email_token(token)
19
- Client.verify_email_token(token)
20
- end
21
-
22
- def create_omniauth_user(provider, access_token)
23
- Client.create_omniauth_user(provider, access_token)
24
- end
25
-
26
- def find_or_create_user_from_account(account)
27
- user = find_user_by_email(account.email)
28
- return user if user
29
-
30
- create_user_from_account(account)
31
- end
32
-
33
- def create_user_from_account(account)
34
- user = ::User.new
35
- user.email = account.email
36
- user.given_name = account.given_name
37
- user.surname = account.surname
38
- user.save
39
-
40
- user
41
- end
42
-
43
- def update_password(password, account)
44
- Client.update_password(password, account)
45
- end
46
-
47
- def id_site_login_url
48
- Client.id_site_url callback_uri: (request.base_url + configuration.id_site.uri)
49
- end
50
-
51
- def id_site_register_url
52
- Client.id_site_url callback_uri: (request.base_url + configuration.id_site.uri), path: '/#register'
53
- end
54
-
55
- def handle_id_site_callback(url)
56
- Client.handle_id_site_callback(url)
57
- end
58
-
59
- def configuration
60
- Stormpath::Rails.config
61
- end
62
-
63
- def find_user_by_email(email)
64
- configuration.user_model.find_user email
65
- end
66
-
67
- def find_user_by_id(id)
68
- configuration.user_model.find(id)
69
- end
70
- end
71
- end
72
- end