revise_auth 0.4.1 → 0.5.0
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 +4 -4
- data/README.md +75 -6
- data/app/controllers/revise_auth/email_controller.rb +3 -3
- data/app/controllers/revise_auth/password_controller.rb +2 -2
- data/app/controllers/revise_auth/password_resets_controller.rb +5 -7
- data/app/controllers/revise_auth/registrations_controller.rb +4 -4
- data/app/controllers/revise_auth/sessions_controller.rb +1 -1
- data/app/views/revise_auth/mailer/confirm_email.html.erb +4 -4
- data/app/views/revise_auth/mailer/password_reset.html.erb +3 -4
- data/app/views/revise_auth/password_resets/edit.html.erb +3 -3
- data/app/views/revise_auth/password_resets/new.html.erb +2 -2
- data/app/views/revise_auth/registrations/edit.html.erb +13 -13
- data/app/views/revise_auth/registrations/new.html.erb +3 -3
- data/app/views/revise_auth/sessions/new.html.erb +3 -3
- data/config/i18n-tasks.yml +161 -0
- data/config/locales/cs.yml +64 -0
- data/config/locales/de.yml +62 -14
- data/config/locales/el.yml +62 -14
- data/config/locales/en.yml +62 -16
- data/config/locales/es.yml +64 -0
- data/config/locales/fr.yml +62 -14
- data/config/locales/nl.yml +63 -15
- data/config/locales/pt.yml +62 -14
- data/config/locales/tr.yml +62 -14
- data/config/locales/zh-TW.yml +62 -14
- data/lib/generators/revise_auth/model_generator.rb +12 -30
- data/lib/generators/revise_auth/templates/README +4 -1
- data/lib/generators/revise_auth/templates/initializer.rb +5 -0
- data/lib/revise_auth/model.rb +7 -2
- data/lib/revise_auth/version.rb +1 -1
- data/lib/revise_auth.rb +5 -0
- metadata +7 -3
data/config/locales/zh-TW.yml
CHANGED
@@ -1,16 +1,64 @@
|
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
+
reset_password: Reset your password
|
64
|
+
sign_up_or_login: 需要註冊或是登入才能進行
|
@@ -1,32 +1,27 @@
|
|
1
1
|
module ReviseAuth
|
2
2
|
module Generators
|
3
|
-
class ModelGenerator < Rails::Generators::
|
4
|
-
|
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 :
|
11
|
-
|
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
|
19
|
-
|
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
|
20
|
+
inject_into_class "app/models/user.rb", "User", " include ReviseAuth::Model\n" if behavior == :invoke
|
24
21
|
end
|
25
22
|
|
26
|
-
def
|
27
|
-
|
28
|
-
", unique: true"
|
29
|
-
end
|
23
|
+
def copy_initializer
|
24
|
+
template "initializer.rb", "config/initializers/revise_auth.rb"
|
30
25
|
end
|
31
26
|
|
32
27
|
def done
|
@@ -38,19 +33,6 @@ module ReviseAuth
|
|
38
33
|
def migration_path
|
39
34
|
@migration_path ||= Dir.glob(Rails.root.join("db/migrate/*")).max_by { |f| File.mtime(f) }
|
40
35
|
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
36
|
end
|
55
37
|
end
|
56
38
|
end
|
data/lib/revise_auth/model.rb
CHANGED
@@ -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..]
|
@@ -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
|
data/lib/revise_auth/version.rb
CHANGED
data/lib/revise_auth.rb
CHANGED
@@ -7,4 +7,9 @@ module ReviseAuth
|
|
7
7
|
autoload :Current, "revise_auth/current"
|
8
8
|
autoload :Model, "revise_auth/model"
|
9
9
|
autoload :RouteConstraint, "revise_auth/route_constraint"
|
10
|
+
|
11
|
+
include ActiveSupport::Configurable
|
12
|
+
|
13
|
+
config_accessor :sign_up_params, default: [:name, :email, :password, :password_confirmation]
|
14
|
+
config_accessor :update_params, default: [:name]
|
10
15
|
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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -62,9 +62,12 @@ 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
|
+
- config/i18n-tasks.yml
|
66
|
+
- config/locales/cs.yml
|
65
67
|
- config/locales/de.yml
|
66
68
|
- config/locales/el.yml
|
67
69
|
- config/locales/en.yml
|
70
|
+
- config/locales/es.yml
|
68
71
|
- config/locales/fr.yml
|
69
72
|
- config/locales/nl.yml
|
70
73
|
- config/locales/pt.yml
|
@@ -72,6 +75,7 @@ files:
|
|
72
75
|
- config/locales/zh-TW.yml
|
73
76
|
- lib/generators/revise_auth/model_generator.rb
|
74
77
|
- lib/generators/revise_auth/templates/README
|
78
|
+
- lib/generators/revise_auth/templates/initializer.rb
|
75
79
|
- lib/generators/revise_auth/views_generator.rb
|
76
80
|
- lib/revise_auth.rb
|
77
81
|
- lib/revise_auth/authentication.rb
|
@@ -104,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
108
|
- !ruby/object:Gem::Version
|
105
109
|
version: '0'
|
106
110
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.5.6
|
108
112
|
signing_key:
|
109
113
|
specification_version: 4
|
110
114
|
summary: Simple authentication for Ruby on Rails apps
|