user_management_rails 0.1.4 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 454e19349bd2cc5c86c5153b6a610ad2c373ce52
4
- data.tar.gz: 59448d316fbf22a3d657c6cdde2d7122efbeef70
2
+ SHA256:
3
+ metadata.gz: 2b32d313222d2d7b0e9e957eeb1e60d1880f74c43537508bddb375ae24d73db7
4
+ data.tar.gz: 9a795605044d0e73b1a569dba6e9eaca01f14477e9d071d98af710b5056c92a3
5
5
  SHA512:
6
- metadata.gz: 4d4d111ab93864f852431b9e531e1d5d3f4174103a1796d00b201f9d54f262c392e9d3b09e3e9994508b4857c045ce5de863fa5bacff0a28b40b9864315e8fe9
7
- data.tar.gz: 3ef9118b9bb071a819af070a72c71150a954d41ef421b6d089394a8c8ae7538bbfe6ede99b42603d0ad2b41d492a6d2043c5900f208664a36a1e77e1d78c5550
6
+ metadata.gz: ed9c00d68fd9829eaf2b7ff9ca2c1b71362081455a8a0c16a6d71ba314e95a6c88717f174f926e9d88f768a987be2ff12284e263d9491b2e2504bc6d13e98e36
7
+ data.tar.gz: 84def8bfbeb4238f5ea03f6f16d4afec77c8271ce35483fe9e742a38059078b9736be7bb5f6ae024a2245749d1e78caefe18b105584129b47ae55df6bba6cde7
data/README.md CHANGED
@@ -5,7 +5,7 @@ Short description and motivation.
5
5
  How to use my plugin.
6
6
  Gem has next methods:
7
7
  `decode_user(jwt)` - expects jwt with user and returns decoded payload(in our case user info).
8
- `valid_jwt?(jwt)` - expects jwt and checks if it is valid. Return `true` when it is valid, otherwise returns `false`
8
+ `valid_jwt?(jwt)` - expects jwt and checks if it is valid. Return `true` when it is valid, otherwise returns `false`
9
9
 
10
10
  Gem adds next endpoints to your application:
11
11
  `/logins` which has next methods:
@@ -16,7 +16,7 @@ Gem provides current_user_hash method for your controller by adding next line to
16
16
  ```ruby
17
17
  include UserManagementRails::Concerns::UserResource
18
18
  ```
19
- It has one optional param `raise_jwt_error` which when true (by default) will rise exception if user jwt has expired.
19
+ It has one optional param `raise_jwt_error` which when true (by default) will rise exception if user jwt has expired.
20
20
  If you don't want to raise exception then pass `false` and when token is expired then jwt will be deleted for cookies.
21
21
 
22
22
  How it works:
@@ -50,7 +50,7 @@ Default routes installed:
50
50
  $ rake routes
51
51
  Prefix Verb URI Pattern Controller#Action
52
52
  user_management_rails / UserManagementRails::Engine
53
- home GET /home(.:format) user_management#loggedin
53
+ home GET /home(.:format) user_management#home
54
54
  login GET /login(.:format) user_management#login
55
55
  root GET / user_management#signup
56
56
 
@@ -58,9 +58,9 @@ Routes for UserManagementRails::Engine:
58
58
  logins POST /logins(.:format) user_management_rails/logins#create
59
59
  ```
60
60
 
61
- ## Requirements
61
+ ## Requirements
62
62
  In your routes.rb file you should specify where `/login` endpoint will be mount.
63
- Example:
63
+ Example:
64
64
  ```ruby
65
65
  mount UserManagementRails::Engine, at: '/'
66
66
  ```
@@ -75,7 +75,7 @@ Then gems `/login` endpoint will be mounted on `domain.com/some_path/logins`
75
75
 
76
76
  ## Adding new version of gem to rubygems repository
77
77
  After you made changes and increment version of gem in(/lib/user_management_rails/version.rb)
78
- you need to build and push new gem file to rubygems.org:
78
+ you need to build and push new gem file to rubygems.org:
79
79
  ```bash
80
80
  gem build user_management_rails.gemspec
81
81
  gem push user_management_rails-<VERSION_OF_GEM>.gem
@@ -15,6 +15,10 @@ module UserManagementRails::Concerns::UserResource
15
15
  result
16
16
  end
17
17
 
18
+ def current_user_logout
19
+ cookies.delete :jwt
20
+ end
21
+
18
22
  private
19
23
 
20
24
  def handle_error
@@ -2,27 +2,31 @@ class UserManagementController < ApplicationController
2
2
  include UserManagementRails::Concerns::UserResource
3
3
 
4
4
  def signup
5
- if current_user_hash
6
- redirect_to action: 'loggedin'
5
+ if current_user_hash(false)
6
+ redirect_to action: 'home'
7
7
  else
8
8
  render 'signup'
9
9
  end
10
10
  end
11
11
 
12
12
  def login
13
- if current_user_hash
14
- redirect_to action: 'loggedin'
13
+ if current_user_hash(false)
14
+ redirect_to action: 'home'
15
15
  else
16
16
  render 'login'
17
17
  end
18
18
  end
19
19
 
20
- def loggedin
21
- if current_user_hash
20
+ def home
21
+ if current_user_hash(false)
22
22
  @userinfo = current_user_hash.values_at("phone","email")
23
23
  else
24
24
  redirect_to action: 'login'
25
25
  end
26
26
  end
27
27
 
28
+ def logout
29
+ current_user_logout
30
+ redirect_to action: 'login'
31
+ end
28
32
  end
@@ -5,5 +5,6 @@
5
5
  <body>
6
6
  <h3>"You Are Logged In as"</h3>
7
7
  <h4><%%= @userinfo %></h4>
8
+ <%%= button_to "Log Out", {:controller => :user_management, :action=> 'logout'} %>
8
9
  </body>
9
10
  </html>
@@ -10,26 +10,18 @@
10
10
 
11
11
  <script type='text/javascript' src="//code.jquery.com/jquery-3.1.1.min.js"></script>
12
12
 
13
- <script type='text/javascript' src="//cdn.rawgit.com/oauth-io/oauth-js/c5af4519/dist/oauth.js"></script>
14
-
15
13
  <script type='text/javascript' src="https://s3.amazonaws.com/ringcaptcha-test/widget/jwt-20180328/bundle.js"></script>
16
14
 
17
-
18
15
  <script type='text/javascript'>
19
16
  $(document).ready(function() {
20
17
  $('#widget-point').append(
21
18
  '<div id="xyz" data-widget data-locale="en" data-mode="login" data-type="dual"></div>'
22
19
  );
23
-
24
20
  $('#xyz').each(function() {
25
- // var appKey = "3i8i2ihu7e9u6orapyga";
26
- // var userManagementId = '0bb071d01611abdf8e76c3';
27
21
  var appKey = "<%%= UserManagementRails.configuration.ringcaptcha_key %>";
28
22
  var userManagementId = "<%%= UserManagementRails.configuration.um_key %>";
29
- var oauthioKey = 'HwAr2OtSxRgEEnO2-JnYjsuA3tc';
30
23
  var settings = $(this).data();
31
24
  // Initialize the SDK
32
- //OAuth.initialize(oauthioKey)
33
25
  settings.app = appKey;
34
26
  settings.events = {
35
27
  login: function(event, formValues) {
@@ -39,8 +31,10 @@
39
31
  const data = dataString ? JSON.parse(dataString) : null;
40
32
  console.log("Login: data:", data);
41
33
  console.log("Login success for:", formValues.login);
42
- $.post('/logins',{jwt:formValues['jwt']});
43
- window.location.replace('./home');
34
+ $.post('/logins',{jwt:formValues['jwt']})
35
+ .done(function() {
36
+ window.location.replace('/home');
37
+ });
44
38
  }
45
39
  };
46
40
  settings.form = [
@@ -10,45 +10,30 @@
10
10
 
11
11
  <script type='text/javascript' src="//code.jquery.com/jquery-3.1.1.min.js"></script>
12
12
 
13
- <script type='text/javascript' src="//cdn.rawgit.com/oauth-io/oauth-js/c5af4519/dist/oauth.js"></script>
14
-
15
13
  <script type='text/javascript' src="https://s3.amazonaws.com/ringcaptcha-test/widget/jwt-20180328/bundle.js"></script>
16
14
 
17
15
  <script>
18
- $(document).ready(function() {
16
+ $(document).ready(function() {
19
17
  $('#widget-point').append(
20
18
  '<div id="xyz" data-widget data-locale="en" data-mode="signup" data-type="dual"></div>'
21
19
  );
22
- $('#xyz').each(function() {
23
- // var appKey = "3i8i2ihu7e9u6orapyga";
24
- // var userManagementId = '0bb071d01611abdf8e76c3';
25
- var appKey = "<%%= UserManagementRails.configuration.ringcaptcha_key %>";
26
- var userManagementId = "<%%= UserManagementRails.configuration.um_key %>";
27
- var oauthioKey = "HwAr2OtSxRgEEnO2-JnYjsuA3tc";
28
- var settings = $(this).data();
29
- // Initialize the SDK
30
- OAuth.initialize(oauthioKey)
31
- settings.app = appKey;
32
- settings.events = {
33
- signup: function(event, formValues) {
34
- console.log("Signup: event:", event);
35
- console.log("Signup: formValues:", formValues);
36
- const dataString = localStorage.getItem('ringcaptcha.widget.' + appKey);
37
- const data = dataString ? JSON.parse(dataString) : null;
38
- console.log("Signup: data:", data);
39
- User.signup({
40
- email: formValues.email,
41
- password: "Freef0rall!",
42
- firstname: "Fname",
43
- lastname: "Lname",
44
- phone: formValues.phone
45
- }).done(function(user) {
46
- console.log("User.signup success for:", formValues.email);
47
- $.post('/logins',{jwt:formValues['jwt']});
48
- window.location.replace('/home');
49
- });
50
- }
51
- };
20
+ $('#xyz').each(function() {
21
+ var appKey = "<%%= UserManagementRails.configuration.ringcaptcha_key %>";
22
+ var userManagementId = "<%%= UserManagementRails.configuration.um_key %>";
23
+ var settings = $(this).data();
24
+ // Initialize the SDK
25
+ settings.app = appKey;
26
+ settings.events = {
27
+ signup: function(event, formValues) {
28
+ console.log("Signup: event:", event);
29
+ console.log("Signup: formValues:", formValues);
30
+ const dataString = localStorage.getItem('ringcaptcha.widget.' + appKey);
31
+ const data = dataString ? JSON.parse(dataString) : null;
32
+ console.log("Signup: data:", data);
33
+ console.log("User.signup success for:", formValues.email);
34
+ window.location.replace('/home');
35
+ }
36
+ };
52
37
  settings.form = [
53
38
  {
54
39
  id: 'email',
@@ -47,14 +47,15 @@ module UserManagementRails
47
47
  "app/views/user_management/signup.html.erb"
48
48
  template "views/login.html.erb",
49
49
  "app/views/user_management/login.html.erb"
50
- template "views/loggedin.html.erb",
51
- "app/views/user_management/loggedin.html.erb"
50
+ template "views/home.html.erb",
51
+ "app/views/user_management/home.html.erb"
52
52
  end
53
53
 
54
54
  def add_routes
55
55
  route "root 'user_management#signup'"
56
+ route "post '/logout', to: 'user_management#logout'"
56
57
  route "get '/login', to: 'user_management#login'"
57
- route "get '/home', to: 'user_management#loggedin'"
58
+ route "get '/home', to: 'user_management#home'"
58
59
  route "mount UserManagementRails::Engine, at: '/'"
59
60
  end
60
61
 
@@ -1,3 +1,3 @@
1
1
  module UserManagementRails
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_management_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RingCaptcha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -208,7 +208,7 @@ files:
208
208
  - lib/generators/templates/README
209
209
  - lib/generators/templates/controllers/user_management_controller.rb
210
210
  - lib/generators/templates/user_management_initializer.rb
211
- - lib/generators/templates/views/loggedin.html.erb
211
+ - lib/generators/templates/views/home.html.erb
212
212
  - lib/generators/templates/views/login.html.erb
213
213
  - lib/generators/templates/views/signup.html.erb
214
214
  - lib/generators/user_management_rails/install_generator.rb
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 2.6.11
239
+ rubygems_version: 2.7.4
240
240
  signing_key:
241
241
  specification_version: 4
242
242
  summary: RingCaptcha widget RoR helper.