tramway-auth 1.2.1 → 1.2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22b1505238d191f5a627db8787628879d1a20520261a9c4d94508134114162d4
4
- data.tar.gz: 5bf1ee01aefa1d8113086d99b6653eb1598cd61d995c2b07d6113377f122cd45
3
+ metadata.gz: 6093468664bc0b122b3fc7bb1cda7a7030581936ce72e3ce4994ba2fd3a9153c
4
+ data.tar.gz: 340ac029ced667dcdddd10e1f201a75e05c447d462de49344dc6671c2890d06b
5
5
  SHA512:
6
- metadata.gz: 6d96c01edb04bff866fae0f9cc125720a3397150980f59056cf34e84335a357ced1f4add6932e783bc7267a100407620ca0d0b3706f924eb3e5738612eb76c19
7
- data.tar.gz: ad4c49be046cee22bfb6c4694fa7ddc96f01ab47480261c8fb650f1c76b7c0109c963a9b240518a57b38a86d16a7491a259a014613a3f75823efda9263824866
6
+ metadata.gz: d3d92bd186abc10659925738a2de77e90ad698b58ce1a1a08013d6f20c324ac7ad9802a0b586b104917fd071cb2e51fcb88a512e6cb6e122232940e115ae9864
7
+ data.tar.gz: e1684587ff576a464a83e79b7add3fd7ac7022f5f0dc86f0d91bf6b9c4c4cd9c3666e4381fee12330f45a368a56c438fb154118ff0860b0b0e518b13219bbbfb
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # Tramway::Auth
2
2
  Short description and motivation.
3
3
 
4
- ## Usage
5
- How to use my plugin.
6
-
7
4
  ## Installation
8
5
  Add this line to your application's Gemfile:
9
6
 
@@ -21,6 +18,47 @@ Or install it yourself as:
21
18
  $ gem install tramway-auth
22
19
  ```
23
20
 
21
+ ## Usage
22
+
23
+ ### Set authentication
24
+
25
+ *config/initializers/tramway/auth.rb*
26
+ ```ruby
27
+ Tramway::Auth.root_path_for YourModel => "/your_path", AnotherYourModel => "/another_path"
28
+ ```
29
+
30
+ ### Add sign up
31
+
32
+ #### 1. Create model sign up form
33
+
34
+ We have `User` model. System will create instances of this model on Sign Up. Then we should create `UserSignUpForm`.
35
+
36
+ ```ruby
37
+ class UserSignUpForm < Tramway::Core::ApplicationForm
38
+ properties :email, :password # you may add all you needed properties here
39
+
40
+ def initiailize(object)
41
+ super(object).tap do
42
+ self.submit_message = 'Sign Up'
43
+ form_properties email: :string,
44
+ first_name: :string,
45
+ last_name: :string,
46
+ password: :default
47
+ end
48
+ end
49
+ end
50
+ ```
51
+
52
+ #### 2. Add password encryption into the User model
53
+
54
+ **Don't forget that User model must inherited of Tramway::Core::ApplicationRecord**
55
+
56
+ ```ruby
57
+ class User < ApplicationRecord
58
+ has_secure_password
59
+ end
60
+ ```
61
+
24
62
  ## Contributing
25
63
  Contribution directions go here.
26
64
 
@@ -6,6 +6,7 @@ module Tramway::Auth
6
6
  before_action :redirect_if_signed_in, except: :destroy
7
7
 
8
8
  def new
9
+ @application = Tramway::Core.application&.model_class&.first || Tramway::Core.application
9
10
  @session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.new
10
11
  end
11
12
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Auth::Web::SignUpsController < Tramway::Auth::Web::ApplicationController
2
4
  before_action :check_authenticable_models
3
5
 
@@ -6,7 +8,7 @@ class Tramway::Auth::Web::SignUpsController < Tramway::Auth::Web::ApplicationCon
6
8
  if @form.submit params[:record]
7
9
  additional_params = { flash: :success }
8
10
  url = if params[:redirect].present?
9
- [ params[:redirect], '?', additional_params.to_query].join
11
+ [params[:redirect], '?', additional_params.to_query].join
10
12
  else
11
13
  Rails.application.routes.url_helpers.root_path(flash: :success)
12
14
  end
@@ -14,7 +16,7 @@ class Tramway::Auth::Web::SignUpsController < Tramway::Auth::Web::ApplicationCon
14
16
  else
15
17
  additional_params = { flash: :error, errors: @form.errors.messages, record: @form.attributes }
16
18
  url = if params[:redirect].present?
17
- [ params[:redirect], '?', additional_params.to_query].join
19
+ [params[:redirect], '?', additional_params.to_query].join
18
20
  else
19
21
  Rails.application.routes.url_helpers.root_path(**additional_params)
20
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Auth
5
- VERSION = '1.2.1'
5
+ VERSION = '1.2.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-08 00:00:00.000000000 Z
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails engine for auth
14
14
  email: