revise_auth 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -7
  3. data/app/controllers/revise_auth/email_controller.rb +3 -3
  4. data/app/controllers/revise_auth/password_controller.rb +2 -2
  5. data/app/controllers/revise_auth/password_resets_controller.rb +5 -7
  6. data/app/controllers/revise_auth/registrations_controller.rb +4 -4
  7. data/app/controllers/revise_auth/sessions_controller.rb +1 -1
  8. data/app/views/revise_auth/mailer/confirm_email.html.erb +4 -4
  9. data/app/views/revise_auth/mailer/password_reset.html.erb +3 -4
  10. data/app/views/revise_auth/password_resets/edit.html.erb +3 -3
  11. data/app/views/revise_auth/password_resets/new.html.erb +4 -2
  12. data/app/views/revise_auth/registrations/edit.html.erb +13 -13
  13. data/app/views/revise_auth/registrations/new.html.erb +5 -3
  14. data/app/views/revise_auth/sessions/new.html.erb +4 -6
  15. data/app/views/revise_auth/shared/_links.html.erb +15 -0
  16. data/config/i18n-tasks.yml +161 -0
  17. data/config/locales/cs.yml +68 -0
  18. data/config/locales/de.yml +66 -14
  19. data/config/locales/el.yml +66 -14
  20. data/config/locales/en.yml +66 -16
  21. data/config/locales/es.yml +68 -0
  22. data/config/locales/fr.yml +66 -14
  23. data/config/locales/nl.yml +67 -15
  24. data/config/locales/pt.yml +66 -14
  25. data/config/locales/tr.yml +66 -14
  26. data/config/locales/zh-TW.yml +66 -14
  27. data/lib/generators/revise_auth/model_generator.rb +16 -30
  28. data/lib/generators/revise_auth/templates/README +4 -1
  29. data/lib/generators/revise_auth/templates/initializer.rb +5 -0
  30. data/lib/revise_auth/authentication.rb +1 -1
  31. data/lib/revise_auth/model.rb +8 -3
  32. data/lib/revise_auth/test/helpers.rb +16 -0
  33. data/lib/revise_auth/version.rb +1 -1
  34. data/lib/revise_auth.rb +10 -0
  35. metadata +12 -7
  36. data/lib/tasks/revise_auth_tasks.rake +0 -4
@@ -1,16 +1,68 @@
1
+ ---
1
2
  tr:
3
+ activerecord:
4
+ attributes:
5
+ user:
6
+ email: Email
7
+ password: Password
8
+ password_challenge: Current password
9
+ password_confirmation: Password confirmation
2
10
  revise_auth:
3
- account_deleted: "Hesabınız silindi."
4
- account_updated: "Hesap başarıyla güncellendi."
5
-
6
- invalid_email_or_password: "Geçersiz e-posta veya şifre."
7
- sign_up_or_login: "Devam etmek için kaydol veya giriş yap."
8
-
9
- # Password changes
10
- password_changed: "Şifreniz başarıyla güncellendi."
11
- incorrect_password: "Şu anki şifreniz yanlış. Lütfen tekrar deneyiniz."
12
-
13
- # Email confirmations
14
- email_confirmed: "E-posta adresiniz başarıyla onaylandı."
15
- email_confirm_failed: "E-posta adresi doğrulanamıyor."
16
- confirmation_email_sent: "%{email} adresine onay e-postası gönderildi."
11
+ email:
12
+ show:
13
+ email_confirm_failed: E-posta adresi doğrulanamıyor.
14
+ email_confirmed: E-posta adresiniz başarıyla onaylandı.
15
+ update:
16
+ confirmation_email_sent: "%{email} adresine onay e-postası gönderildi."
17
+ mailer:
18
+ confirm_email:
19
+ confirm: Confirm my account
20
+ confirm_below: 'You can confirm your account email through the link below:'
21
+ expiration_notice: This link will expire in 24 hours.
22
+ welcome: Welcome %{email}!
23
+ password_reset:
24
+ expiration_notice: This link will expire in 1 hour.
25
+ reset_password: Reset my password
26
+ reset_password_below: We've received a password reset request for your login. If this was you just visit the link below to finish up. If it wasn't you, you can simply ignore this email.
27
+ password:
28
+ update:
29
+ incorrect_password: Şu anki şifreniz yanlış. Lütfen tekrar deneyiniz.
30
+ password_changed: Şifreniz başarıyla güncellendi.
31
+ password_resets:
32
+ create:
33
+ password_reset_sent: An email with password reset instructions has been sent if that account exists.
34
+ edit:
35
+ invalid_password_link: The provided password reset link is invalid.
36
+ reset_password: Reset password
37
+ new:
38
+ send_password_reset_instructions: Send Password Reset Instructions
39
+ registrations:
40
+ destroy:
41
+ account_deleted: Hesabınız silindi.
42
+ edit:
43
+ change_email_address: Change Email Address
44
+ change_password: Change Password
45
+ confirm: Are you sure?
46
+ confirmation_instructions: To change your email, we will send a confirmation email to your new address to complete the change.
47
+ current_email_address: 'Your email address is: %{email}.'
48
+ delete_account: Delete my account
49
+ new_email: New Email
50
+ new_password: New password
51
+ profile: Profile
52
+ save: Save Changes
53
+ waiting_confirmation: Waiting for confirmation of %{email}.
54
+ new:
55
+ sign_up: Sign up
56
+ update:
57
+ account_updated: Hesap başarıyla güncellendi.
58
+ sessions:
59
+ create:
60
+ invalid_email_or_password: Geçersiz e-posta veya şifre.
61
+ new:
62
+ log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
66
+ reset_password: Reset your password
67
+ sign_up: Sign up
68
+ sign_up_or_login: Devam etmek için kaydol veya giriş yap.
@@ -1,16 +1,68 @@
1
+ ---
1
2
  zh-TW:
3
+ activerecord:
4
+ attributes:
5
+ user:
6
+ email: Email
7
+ password: Password
8
+ password_challenge: Current password
9
+ password_confirmation: Password confirmation
2
10
  revise_auth:
3
- account_deleted: "您的帳號已經被刪除"
4
- account_updated: "帳號更新成功"
5
-
6
- invalid_email_or_password: "錯誤的信箱或是密碼"
7
- sign_up_or_login: "需要註冊或是登入才能進行"
8
-
9
- # Password changes
10
- password_changed: "您的密碼已經成功地更新"
11
- incorrect_password: "您現在輸入的密碼不正確, 請重新嘗試"
12
-
13
- # Email confirmations
14
- email_confirmed: "您的電子信箱已經成功地通過驗證"
15
- email_confirm_failed: "無法驗證您的電子信箱"
16
- confirmation_email_sent: "電子信箱驗證信已寄往 %{email}"
11
+ email:
12
+ show:
13
+ email_confirm_failed: 無法驗證您的電子信箱
14
+ email_confirmed: 您的電子信箱已經成功地通過驗證
15
+ update:
16
+ confirmation_email_sent: 電子信箱驗證信已寄往 %{email}
17
+ mailer:
18
+ confirm_email:
19
+ confirm: Confirm my account
20
+ confirm_below: 'You can confirm your account email through the link below:'
21
+ expiration_notice: This link will expire in 24 hours.
22
+ welcome: Welcome %{email}!
23
+ password_reset:
24
+ expiration_notice: This link will expire in 1 hour.
25
+ reset_password: Reset my password
26
+ reset_password_below: We've received a password reset request for your login. If this was you just visit the link below to finish up. If it wasn't you, you can simply ignore this email.
27
+ password:
28
+ update:
29
+ incorrect_password: 您現在輸入的密碼不正確, 請重新嘗試
30
+ password_changed: 您的密碼已經成功地更新
31
+ password_resets:
32
+ create:
33
+ password_reset_sent: An email with password reset instructions has been sent if that account exists.
34
+ edit:
35
+ invalid_password_link: The provided password reset link is invalid.
36
+ reset_password: Reset password
37
+ new:
38
+ send_password_reset_instructions: Send Password Reset Instructions
39
+ registrations:
40
+ destroy:
41
+ account_deleted: 您的帳號已經被刪除
42
+ edit:
43
+ change_email_address: Change Email Address
44
+ change_password: Change Password
45
+ confirm: Are you sure?
46
+ confirmation_instructions: To change your email, we will send a confirmation email to your new address to complete the change.
47
+ current_email_address: 'Your email address is: %{email}.'
48
+ delete_account: Delete my account
49
+ new_email: New Email
50
+ new_password: New password
51
+ profile: Profile
52
+ save: Save Changes
53
+ waiting_confirmation: Waiting for confirmation of %{email}.
54
+ new:
55
+ sign_up: Sign up
56
+ update:
57
+ account_updated: 帳號更新成功
58
+ sessions:
59
+ create:
60
+ invalid_email_or_password: 錯誤的信箱或是密碼
61
+ new:
62
+ log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
66
+ reset_password: Reset your password
67
+ sign_up: Sign up
68
+ sign_up_or_login: 需要註冊或是登入才能進行
@@ -1,32 +1,31 @@
1
1
  module ReviseAuth
2
2
  module Generators
3
- class ModelGenerator < Rails::Generators::NamedBase
4
- include Rails::Generators::ResourceHelpers
5
-
6
- desc "Generates a model for authentication, default User"
3
+ class ModelGenerator < Rails::Generators::Base
4
+ desc "Generates the User model for authentication"
7
5
 
8
6
  source_root File.expand_path("templates", __dir__)
9
7
 
10
- argument :name, required: false, default: "User"
11
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
12
-
13
- def initialize(args, *options)
14
- @original_attributes = args[1..] || []
15
- super
8
+ argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
9
+ hook_for :orm, required: true, desc: "ORM to be invoked" do |instance, model|
10
+ instance.invoke model, ["User", "email:string:uniq", "password_digest:string", "confirmed_at:datetime", "unconfirmed_email:string", *instance.attributes]
16
11
  end
17
12
 
18
- def generate_model
19
- generate :model, name, *model_attributes
13
+ def change_attributes_null
14
+ return unless behavior == :invoke
15
+ gsub_file migration_path, /t\.string :email$/, "t.string :email, null: false"
16
+ gsub_file migration_path, /t\.string :password_digest$/, "t.string :password_digest, null: false"
20
17
  end
21
18
 
22
19
  def add_revise_auth_model
23
- inject_into_class model_path, class_name, " include ReviseAuth::Model\n"
20
+ inject_into_class "app/models/user.rb", "User", " include ReviseAuth::Model\n" if behavior == :invoke
21
+ end
22
+
23
+ def add_revise_auth_routes
24
+ route "revise_auth"
24
25
  end
25
26
 
26
- def add_uniq_to_email_index
27
- insert_into_file migration_path, after: "#{name.downcase.pluralize}, :email", force: true do
28
- ", unique: true"
29
- end
27
+ def copy_initializer
28
+ template "initializer.rb", "config/initializers/revise_auth.rb"
30
29
  end
31
30
 
32
31
  def done
@@ -38,19 +37,6 @@ module ReviseAuth
38
37
  def migration_path
39
38
  @migration_path ||= Dir.glob(Rails.root.join("db/migrate/*")).max_by { |f| File.mtime(f) }
40
39
  end
41
-
42
- def model_path
43
- @model_path ||= File.join("app", "models", "#{file_path}.rb")
44
- end
45
-
46
- def model_attributes
47
- [
48
- "email:string:index",
49
- "password_digest:string",
50
- "confirmed_at:datetime",
51
- "unconfirmed_email:string"
52
- ] + @original_attributes
53
- end
54
40
  end
55
41
  end
56
42
  end
@@ -1,4 +1,7 @@
1
- 🚚 Your Revise auth database model has been generated!
1
+ 🚚 Your ReviseAuth User has been generated!
2
2
 
3
3
  Next step:
4
4
  Run "rails db:migrate"
5
+
6
+ To customize views:
7
+ Run "rails generate revise_auth:views"
@@ -0,0 +1,5 @@
1
+ ReviseAuth.configure do |config|
2
+ # Customize the params for registration and update profile.
3
+ # config.sign_up_params += [:time_zone]
4
+ # config.update_params += [:time_zone]
5
+ end
@@ -70,7 +70,7 @@ module ReviseAuth
70
70
  # the controllers defined inside revise_auth. Useful if you want to apply a before
71
71
  # filter to all controllers, except the ones in revise_auth:
72
72
  #
73
- # before_action :authenticate_user!, except: :revise_auth_controller?
73
+ # before_action :authenticate_user!, unless: :revise_auth_controller?
74
74
  def revise_auth_controller?
75
75
  is_a?(::ReviseAuthController)
76
76
  end
@@ -7,7 +7,6 @@ module ReviseAuth
7
7
  base.const_set :PASSWORD_RESET_TOKEN_VALIDITY, 1.hour
8
8
 
9
9
  has_secure_password
10
- has_secure_token :confirmation_token
11
10
 
12
11
  generates_token_for :password_reset, expires_in: base.const_get(:PASSWORD_RESET_TOKEN_VALIDITY) do
13
12
  BCrypt::Password.new(password_digest).salt[-10..]
@@ -22,7 +21,7 @@ module ReviseAuth
22
21
 
23
22
  validates :email, format: {with: URI::MailTo::EMAIL_REGEXP}, presence: true, uniqueness: true
24
23
  validates :unconfirmed_email, format: {with: URI::MailTo::EMAIL_REGEXP}, allow_blank: true
25
- validates_length_of :password, minimum: 12, allow_nil: true
24
+ validates_length_of :password, minimum: ReviseAuth.minimum_password_length, allow_nil: true
26
25
  end
27
26
 
28
27
  # Generates a confirmation token and send email to the user
@@ -31,8 +30,14 @@ module ReviseAuth
31
30
  ReviseAuth::Mailer.with(user: self, token: token).confirm_email.deliver_later
32
31
  end
33
32
 
33
+ # Generates a password reset token and send email to the user
34
+ def send_password_reset_instructions
35
+ token = generate_token_for(:password_reset)
36
+ ReviseAuth::Mailer.with(user: self, token: token).password_reset.deliver_later
37
+ end
38
+
34
39
  def confirm_email_change
35
- update(confirmed_at: Time.current, email: unconfirmed_email)
40
+ update(confirmed_at: Time.current, email: unconfirmed_email, unconfirmed_email: nil)
36
41
  end
37
42
  end
38
43
  end
@@ -0,0 +1,16 @@
1
+ module ReviseAuth
2
+ module Test
3
+ module Helpers
4
+ def login(user, password: "password")
5
+ post login_path, params: {
6
+ email: user.email,
7
+ password: password
8
+ }
9
+ end
10
+
11
+ def logout
12
+ delete logout_path
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.4.1"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/revise_auth.rb CHANGED
@@ -3,8 +3,18 @@ require "revise_auth/engine"
3
3
  require "revise_auth/routes"
4
4
 
5
5
  module ReviseAuth
6
+ include ActiveSupport::Configurable
7
+
6
8
  autoload :Authentication, "revise_auth/authentication"
7
9
  autoload :Current, "revise_auth/current"
8
10
  autoload :Model, "revise_auth/model"
9
11
  autoload :RouteConstraint, "revise_auth/route_constraint"
12
+
13
+ module Test
14
+ autoload :Helpers, "revise_auth/test/helpers"
15
+ end
16
+
17
+ config_accessor :sign_up_params, default: [:email, :password, :password_confirmation]
18
+ config_accessor :update_params, default: []
19
+ config_accessor :minimum_password_length, default: 12
10
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revise_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-02 00:00:00.000000000 Z
11
+ date: 2024-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -62,9 +62,13 @@ files:
62
62
  - app/views/revise_auth/registrations/edit.html.erb
63
63
  - app/views/revise_auth/registrations/new.html.erb
64
64
  - app/views/revise_auth/sessions/new.html.erb
65
+ - app/views/revise_auth/shared/_links.html.erb
66
+ - config/i18n-tasks.yml
67
+ - config/locales/cs.yml
65
68
  - config/locales/de.yml
66
69
  - config/locales/el.yml
67
70
  - config/locales/en.yml
71
+ - config/locales/es.yml
68
72
  - config/locales/fr.yml
69
73
  - config/locales/nl.yml
70
74
  - config/locales/pt.yml
@@ -72,6 +76,7 @@ files:
72
76
  - config/locales/zh-TW.yml
73
77
  - lib/generators/revise_auth/model_generator.rb
74
78
  - lib/generators/revise_auth/templates/README
79
+ - lib/generators/revise_auth/templates/initializer.rb
75
80
  - lib/generators/revise_auth/views_generator.rb
76
81
  - lib/revise_auth.rb
77
82
  - lib/revise_auth/authentication.rb
@@ -80,8 +85,8 @@ files:
80
85
  - lib/revise_auth/model.rb
81
86
  - lib/revise_auth/route_constraint.rb
82
87
  - lib/revise_auth/routes.rb
88
+ - lib/revise_auth/test/helpers.rb
83
89
  - lib/revise_auth/version.rb
84
- - lib/tasks/revise_auth_tasks.rake
85
90
  homepage: https://github.com/excid3/revise_auth
86
91
  licenses:
87
92
  - MIT
@@ -89,7 +94,7 @@ metadata:
89
94
  homepage_uri: https://github.com/excid3/revise_auth
90
95
  source_code_uri: https://github.com/excid3/revise_auth
91
96
  changelog_uri: https://github.com/excid3/revise_auth/blob/main/CHANGELOG.md
92
- post_install_message:
97
+ post_install_message:
93
98
  rdoc_options: []
94
99
  require_paths:
95
100
  - lib
@@ -104,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
109
  - !ruby/object:Gem::Version
105
110
  version: '0'
106
111
  requirements: []
107
- rubygems_version: 3.4.20
108
- signing_key:
112
+ rubygems_version: 3.5.9
113
+ signing_key:
109
114
  specification_version: 4
110
115
  summary: Simple authentication for Ruby on Rails apps
111
116
  test_files: []
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :revise_auth do
3
- # # Task goes here
4
- # end