devise_jwt_auth 0.1.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 +7 -0
- data/LICENSE +13 -0
- data/README.md +99 -0
- data/Rakefile +42 -0
- data/app/controllers/devise_jwt_auth/application_controller.rb +80 -0
- data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +44 -0
- data/app/controllers/devise_jwt_auth/concerns/set_user_by_jwt_token.rb +111 -0
- data/app/controllers/devise_jwt_auth/confirmations_controller.rb +88 -0
- data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +291 -0
- data/app/controllers/devise_jwt_auth/passwords_controller.rb +217 -0
- data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +41 -0
- data/app/controllers/devise_jwt_auth/registrations_controller.rb +203 -0
- data/app/controllers/devise_jwt_auth/sessions_controller.rb +131 -0
- data/app/controllers/devise_jwt_auth/unlocks_controller.rb +99 -0
- data/app/models/devise_jwt_auth/concerns/active_record_support.rb +16 -0
- data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +27 -0
- data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +19 -0
- data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +19 -0
- data/app/models/devise_jwt_auth/concerns/user.rb +117 -0
- data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +28 -0
- data/app/validators/devise_jwt_auth_email_validator.rb +23 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise_jwt_auth/omniauth_external_window.html.erb +38 -0
- data/config/locales/da-DK.yml +52 -0
- data/config/locales/de.yml +51 -0
- data/config/locales/en.yml +57 -0
- data/config/locales/es.yml +51 -0
- data/config/locales/fr.yml +51 -0
- data/config/locales/he.yml +52 -0
- data/config/locales/it.yml +48 -0
- data/config/locales/ja.yml +48 -0
- data/config/locales/ko.yml +51 -0
- data/config/locales/nl.yml +32 -0
- data/config/locales/pl.yml +50 -0
- data/config/locales/pt-BR.yml +48 -0
- data/config/locales/pt.yml +50 -0
- data/config/locales/ro.yml +48 -0
- data/config/locales/ru.yml +52 -0
- data/config/locales/sq.yml +48 -0
- data/config/locales/sv.yml +52 -0
- data/config/locales/uk.yml +61 -0
- data/config/locales/vi.yml +52 -0
- data/config/locales/zh-CN.yml +48 -0
- data/config/locales/zh-HK.yml +50 -0
- data/config/locales/zh-TW.yml +50 -0
- data/lib/devise_jwt_auth.rb +14 -0
- data/lib/devise_jwt_auth/blacklist.rb +2 -0
- data/lib/devise_jwt_auth/controllers/helpers.rb +161 -0
- data/lib/devise_jwt_auth/controllers/url_helpers.rb +10 -0
- data/lib/devise_jwt_auth/engine.rb +96 -0
- data/lib/devise_jwt_auth/errors.rb +8 -0
- data/lib/devise_jwt_auth/rails/routes.rb +118 -0
- data/lib/devise_jwt_auth/token_factory.rb +51 -0
- data/lib/devise_jwt_auth/url.rb +44 -0
- data/lib/devise_jwt_auth/version.rb +5 -0
- data/lib/generators/devise_jwt_auth/USAGE +31 -0
- data/lib/generators/devise_jwt_auth/install_generator.rb +91 -0
- data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +98 -0
- data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +46 -0
- data/lib/generators/devise_jwt_auth/install_views_generator.rb +18 -0
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +74 -0
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +51 -0
- data/lib/generators/devise_jwt_auth/templates/user.rb.erb +9 -0
- data/lib/generators/devise_jwt_auth/templates/user_mongoid.rb.erb +56 -0
- data/lib/tasks/devise_token_auth_tasks.rake +6 -0
- data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
- data/test/controllers/custom/custom_refresh_token_controller_test.rb +36 -0
- data/test/controllers/custom/custom_registrations_controller_test.rb +59 -0
- data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
- data/test/controllers/demo_group_controller_test.rb +150 -0
- data/test/controllers/demo_mang_controller_test.rb +286 -0
- data/test/controllers/demo_user_controller_test.rb +650 -0
- data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +194 -0
- data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +462 -0
- data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +881 -0
- data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +84 -0
- data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +944 -0
- data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +510 -0
- data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +197 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
- data/test/controllers/overrides/passwords_controller_test.rb +65 -0
- data/test/controllers/overrides/refresh_token_controller_test.rb +37 -0
- data/test/controllers/overrides/registrations_controller_test.rb +47 -0
- data/test/controllers/overrides/sessions_controller_test.rb +35 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/app/active_record/confirmable_user.rb +11 -0
- data/test/dummy/app/active_record/lockable_user.rb +7 -0
- data/test/dummy/app/active_record/mang.rb +5 -0
- data/test/dummy/app/active_record/only_email_user.rb +7 -0
- data/test/dummy/app/active_record/scoped_user.rb +9 -0
- data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
- data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
- data/test/dummy/app/active_record/user.rb +6 -0
- data/test/dummy/app/controllers/application_controller.rb +18 -0
- data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/refresh_token_controller.rb +20 -0
- data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
- data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +37 -0
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +45 -0
- data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +22 -0
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
- data/test/dummy/app/helpers/application_helper.rb +1058 -0
- data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
- data/test/dummy/app/mongoid/confirmable_user.rb +52 -0
- data/test/dummy/app/mongoid/lockable_user.rb +38 -0
- data/test/dummy/app/mongoid/mang.rb +46 -0
- data/test/dummy/app/mongoid/only_email_user.rb +33 -0
- data/test/dummy/app/mongoid/scoped_user.rb +50 -0
- data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
- data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
- data/test/dummy/app/mongoid/user.rb +49 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +18 -0
- data/test/dummy/config/application.rb +48 -0
- data/test/dummy/config/application.yml.bk +0 -0
- data/test/dummy/config/boot.rb +11 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/development.rb +46 -0
- data/test/dummy/config/environments/production.rb +84 -0
- data/test/dummy/config/environments/test.rb +50 -0
- data/test/dummy/config/initializers/assets.rb +10 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/devise.rb +290 -0
- data/test/dummy/config/initializers/devise_jwt_auth.rb +55 -0
- data/test/dummy/config/initializers/figaro.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +18 -0
- data/test/dummy/config/initializers/mime_types.rb +6 -0
- data/test/dummy/config/initializers/omniauth.rb +11 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/test/dummy/config/routes.rb +57 -0
- data/test/dummy/config/spring.rb +3 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +58 -0
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +57 -0
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +55 -0
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +56 -0
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +56 -0
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +56 -0
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +56 -0
- data/test/dummy/db/migrate/20190924101113_devise_token_auth_create_confirmable_users.rb +49 -0
- data/test/dummy/db/schema.rb +198 -0
- data/test/dummy/lib/migration_database_helper.rb +43 -0
- data/test/dummy/tmp/generators/app/models/user.rb +9 -0
- data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +74 -0
- data/test/dummy/tmp/generators/config/routes.rb +4 -0
- data/test/dummy/tmp/generators/db/migrate/20200206224309_devise_jwt_auth_create_users.rb +51 -0
- data/test/factories/users.rb +41 -0
- data/test/lib/devise_jwt_auth/blacklist_test.rb +11 -0
- data/test/lib/devise_jwt_auth/token_factory_test.rb +115 -0
- data/test/lib/devise_jwt_auth/url_test.rb +26 -0
- data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +219 -0
- data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +224 -0
- data/test/lib/generators/devise_jwt_auth/install_views_generator_test.rb +25 -0
- data/test/models/concerns/mongoid_support_test.rb +31 -0
- data/test/models/concerns/tokens_serialization_test.rb +72 -0
- data/test/models/confirmable_user_test.rb +35 -0
- data/test/models/only_email_user_test.rb +29 -0
- data/test/models/user_test.rb +110 -0
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +91 -0
- metadata +503 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative 'tokens_serialization'
|
|
2
|
+
|
|
3
|
+
module DeviseJwtAuth::Concerns::ActiveRecordSupport
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
serialize :tokens, DeviseJwtAuth::Concerns::TokensSerialization
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class_methods do
|
|
11
|
+
# It's abstract replacement .find_by
|
|
12
|
+
def dta_find_by(attrs = {})
|
|
13
|
+
find_by(attrs)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module DeviseJwtAuth::Concerns::ConfirmableSupport
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
# Override standard devise `postpone_email_change?` method
|
|
6
|
+
# for not to use `will_save_change_to_email?` & `email_changed?` methods.
|
|
7
|
+
def postpone_email_change?
|
|
8
|
+
postpone = self.class.reconfirmable &&
|
|
9
|
+
email_value_in_database != email &&
|
|
10
|
+
!@bypass_confirmation_postpone &&
|
|
11
|
+
self.email.present? &&
|
|
12
|
+
(!@skip_reconfirmation_in_callback || !email_value_in_database.nil?)
|
|
13
|
+
@bypass_confirmation_postpone = false
|
|
14
|
+
postpone
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def email_value_in_database
|
|
21
|
+
if Devise.rails51? && respond_to?(:email_in_database)
|
|
22
|
+
email_in_database
|
|
23
|
+
else
|
|
24
|
+
email_was
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module DeviseJwtAuth::Concerns::MongoidSupport
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
def as_json(options = {})
|
|
5
|
+
options[:except] = (options[:except] || []) + [:_id]
|
|
6
|
+
hash = super(options)
|
|
7
|
+
hash['id'] = to_param
|
|
8
|
+
hash
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class_methods do
|
|
12
|
+
# It's abstract replacement .find_by
|
|
13
|
+
def dta_find_by(attrs = {})
|
|
14
|
+
find_by(attrs)
|
|
15
|
+
rescue Mongoid::Errors::DocumentNotFound
|
|
16
|
+
nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module DeviseJwtAuth::Concerns::TokensSerialization
|
|
2
|
+
# Serialization hash to json
|
|
3
|
+
def self.dump(object)
|
|
4
|
+
object.each_value(&:compact!) unless object.nil?
|
|
5
|
+
JSON.generate(object)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Deserialization json to hash
|
|
9
|
+
def self.load(json)
|
|
10
|
+
case json
|
|
11
|
+
when String
|
|
12
|
+
JSON.parse(json)
|
|
13
|
+
when NilClass
|
|
14
|
+
{}
|
|
15
|
+
else
|
|
16
|
+
json
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'jwt'
|
|
4
|
+
|
|
5
|
+
module DeviseJwtAuth::Concerns::User
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
# Hack to check if devise is already enabled
|
|
10
|
+
if method_defined?(:devise_modules)
|
|
11
|
+
devise_modules.delete(:omniauthable)
|
|
12
|
+
else
|
|
13
|
+
devise :database_authenticatable, :registerable,
|
|
14
|
+
:recoverable, :validatable, :confirmable
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if const_defined?('ActiveRecord') && ancestors.include?(ActiveRecord::Base)
|
|
18
|
+
include DeviseJwtAuth::Concerns::ActiveRecordSupport
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if const_defined?('Mongoid') && ancestors.include?(Mongoid::Document)
|
|
22
|
+
include DeviseJwtAuth::Concerns::MongoidSupport
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if DeviseJwtAuth.default_callbacks
|
|
26
|
+
include DeviseJwtAuth::Concerns::UserOmniauthCallbacks
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# don't use default devise email validation
|
|
30
|
+
def email_required?; false; end
|
|
31
|
+
def email_changed?; false; end
|
|
32
|
+
def will_save_change_to_email?; false; end
|
|
33
|
+
|
|
34
|
+
if DeviseJwtAuth.send_confirmation_email && devise_modules.include?(:confirmable)
|
|
35
|
+
include DeviseJwtAuth::Concerns::ConfirmableSupport
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def password_required?
|
|
39
|
+
return false unless provider == 'email'
|
|
40
|
+
super
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# override devise method to include additional info as opts hash
|
|
44
|
+
def send_confirmation_instructions(opts = {})
|
|
45
|
+
generate_confirmation_token! unless @raw_confirmation_token
|
|
46
|
+
|
|
47
|
+
# fall back to "default" config name
|
|
48
|
+
opts[:client_config] ||= 'default'
|
|
49
|
+
opts[:to] = unconfirmed_email if pending_reconfirmation?
|
|
50
|
+
opts[:redirect_url] ||= DeviseJwtAuth.default_confirm_success_url
|
|
51
|
+
|
|
52
|
+
send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# override devise method to include additional info as opts hash
|
|
56
|
+
def send_reset_password_instructions(opts = {})
|
|
57
|
+
token = set_reset_password_token
|
|
58
|
+
|
|
59
|
+
# fall back to "default" config name
|
|
60
|
+
opts[:client_config] ||= 'default'
|
|
61
|
+
|
|
62
|
+
send_devise_notification(:reset_password_instructions, token, opts)
|
|
63
|
+
token
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# override devise method to include additional info as opts hash
|
|
67
|
+
def send_unlock_instructions(opts = {})
|
|
68
|
+
raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
|
|
69
|
+
self.unlock_token = enc
|
|
70
|
+
save(validate: false)
|
|
71
|
+
|
|
72
|
+
# fall back to "default" config name
|
|
73
|
+
opts[:client_config] ||= 'default'
|
|
74
|
+
|
|
75
|
+
send_devise_notification(:unlock_instructions, raw, opts)
|
|
76
|
+
raw
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def create_token(token_options = {})
|
|
80
|
+
DeviseJwtAuth::TokenFactory.create_access_token({sub: uid}.merge(token_options))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def create_refresh_token(token_options = {})
|
|
84
|
+
DeviseJwtAuth::TokenFactory.create_refresh_token({sub: uid}.merge(token_options))
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Returns a hash that you can merge into a json response or in the case of
|
|
89
|
+
# testing, merge it into a testing request.
|
|
90
|
+
def create_named_token_pair(token_options = {})
|
|
91
|
+
{ DeviseJwtAuth.access_token_name.to_sym => create_token(token_options) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# this must be done from the controller so that additional params
|
|
95
|
+
# can be passed on from the client
|
|
96
|
+
def send_confirmation_notification?; false; end
|
|
97
|
+
|
|
98
|
+
def build_auth_url(base_url, args)
|
|
99
|
+
args[:uid] = uid
|
|
100
|
+
args[:expiry] = tokens[args[:client_id]]['expiry']
|
|
101
|
+
|
|
102
|
+
DeviseJwtAuth::Url.generate(base_url, args)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def extend_batch_buffer(token, client)
|
|
106
|
+
tokens[client]['updated_at'] = Time.zone.now
|
|
107
|
+
update_auth_header(token, client)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def confirmed?
|
|
111
|
+
devise_modules.exclude?(:confirmable) || super
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def token_validation_response
|
|
115
|
+
as_json(except: %i[tokens created_at updated_at])
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module DeviseJwtAuth::Concerns::UserOmniauthCallbacks
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
validates :email, presence: true,if: :email_provider?
|
|
8
|
+
validates :email, :devise_jwt_auth_email => true, allow_nil: true, allow_blank: true, if: :email_provider?
|
|
9
|
+
validates_presence_of :uid, unless: :email_provider?
|
|
10
|
+
|
|
11
|
+
# only validate unique emails among email registration users
|
|
12
|
+
validates :email, uniqueness: { case_sensitive: false, scope: :provider }, on: :create, if: :email_provider?
|
|
13
|
+
|
|
14
|
+
# keep uid in sync with email
|
|
15
|
+
before_save :sync_uid
|
|
16
|
+
before_create :sync_uid
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
protected
|
|
20
|
+
|
|
21
|
+
def email_provider?
|
|
22
|
+
provider == 'email'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def sync_uid
|
|
26
|
+
self.uid = email if email_provider?
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class DeviseJwtAuthEmailValidator < ActiveModel::EachValidator
|
|
4
|
+
def validate_each(record, attribute, value)
|
|
5
|
+
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
|
6
|
+
record.errors[attribute] << email_invalid_message
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def email_invalid_message
|
|
13
|
+
# Try strictly set message:
|
|
14
|
+
message = options[:message]
|
|
15
|
+
|
|
16
|
+
if message.nil?
|
|
17
|
+
# Try DeviceTokenAuth translations or fallback to ActiveModel translations
|
|
18
|
+
message = I18n.t(:'errors.messages.not_email', default: :'errors.messages.invalid')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
message
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<p><%= t(:welcome).capitalize + ' ' + @email %>!</p>
|
|
2
|
+
|
|
3
|
+
<p><%= t '.confirm_link_msg' %> </p>
|
|
4
|
+
|
|
5
|
+
<p><%= link_to t('.confirm_account_link'), confirmation_url(@resource, {confirmation_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url']}).html_safe %></p>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<p><%= t(:hello).capitalize %> <%= @resource.email %>!</p>
|
|
2
|
+
|
|
3
|
+
<p><%= t '.request_reset_link_msg' %></p>
|
|
4
|
+
|
|
5
|
+
<p><%= link_to t('.password_change_link'), edit_password_url(@resource, reset_password_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s).html_safe %></p>
|
|
6
|
+
|
|
7
|
+
<p><%= t '.ignore_mail_msg' %></p>
|
|
8
|
+
<p><%= t '.no_changes_msg' %></p>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<script>
|
|
5
|
+
/*
|
|
6
|
+
The data is accessible in two ways:
|
|
7
|
+
|
|
8
|
+
1. Using the postMessage api, this window will respond to a
|
|
9
|
+
'message' event with a post of all the data. (This can
|
|
10
|
+
be used by browsers other than IE if this window was
|
|
11
|
+
opened with window.open())
|
|
12
|
+
2. This window has a function called requestCredentials which,
|
|
13
|
+
when called, will return the data. (This can be
|
|
14
|
+
used if this window was opened in an inAppBrowser using
|
|
15
|
+
Cordova / PhoneGap)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var data = JSON.parse(decodeURIComponent('<%= URI::escape( @data.to_json ) %>'));
|
|
19
|
+
|
|
20
|
+
window.addEventListener("message", function(ev) {
|
|
21
|
+
if (ev.data === "requestCredentials") {
|
|
22
|
+
ev.source.postMessage(data, '*');
|
|
23
|
+
window.close();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
function requestCredentials() {
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
setTimeout(function() {
|
|
30
|
+
document.getElementById('text').innerHTML = (data && data.error) || 'Redirecting...';
|
|
31
|
+
}, 1000);
|
|
32
|
+
</script>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<pre id="text">
|
|
36
|
+
</pre>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
da-DK:
|
|
2
|
+
devise_jwt_auth:
|
|
3
|
+
sessions:
|
|
4
|
+
not_confirmed: "Der er sendt en bekræftelsesemail til din konto på '%{email}'. Følg venligst instruktionerne i emailen for at aktivere din konto."
|
|
5
|
+
bad_credentials: "Ugyldig kombination af brugernavn og kodeord. Prøv venligst igen."
|
|
6
|
+
not_supported: "Brug POST /sign_in for at logge ind. GET er ikke supporteret."
|
|
7
|
+
user_not_found: "Brugeren er ikke fundet eller er ikke logget ind."
|
|
8
|
+
token_validations:
|
|
9
|
+
invalid: "Ugyldige legitimationsoplysninger."
|
|
10
|
+
registrations:
|
|
11
|
+
missing_confirm_success_url: "Der mangler et 'confirm_success_url' parameter."
|
|
12
|
+
redirect_url_not_allowed: "Omdirigering til '%{redirect_url}' er ikke tilladt."
|
|
13
|
+
email_already_exists: "Der eksisterer allerede en konto med '%{email}'"
|
|
14
|
+
account_with_uid_destroyed: "Kontoen med UID '%{uid}' er slettet."
|
|
15
|
+
account_to_destroy_not_found: "Kan ikke finde kontoen som skal slettes."
|
|
16
|
+
user_not_found: "Brugeren ikke fundet."
|
|
17
|
+
omniauth:
|
|
18
|
+
not_allowed_redirect_url: "Omdirigering til '%{redirect_url}' er ikke tilladt."
|
|
19
|
+
passwords:
|
|
20
|
+
missing_email: "Du skal udfylde email feltet."
|
|
21
|
+
missing_redirect_url: "Der er ingen omdirigeringsadresse."
|
|
22
|
+
redirect_url_not_allowed: "Omdirigering til '%{redirect_url}' er ikke tilladt."
|
|
23
|
+
sended: "En email er blevet sendt til '%{email}' med instruktioner for at nulstille dit kodeord."
|
|
24
|
+
user_not_found: "Kan ikke finde en bruger med '%{email}'."
|
|
25
|
+
password_not_required: "Denne bruger kræver ikke et kodeord. Log ind med '%{provider}' konto i stedet."
|
|
26
|
+
missing_passwords: "Du skal udfylde både kodeord og bekræftelse af kodeord."
|
|
27
|
+
successfully_updated: "Dit kodeord er opdateret."
|
|
28
|
+
unlocks:
|
|
29
|
+
missing_email: "Du skal udfylde en email."
|
|
30
|
+
sended: "En email er blevet sendt til '%{email}', som indeholder instruktioner for at låse kontoen op."
|
|
31
|
+
user_not_found: "Kan ikke finde en bruger med email '%{email}'."
|
|
32
|
+
errors:
|
|
33
|
+
messages:
|
|
34
|
+
validate_sign_up_params: "Angiv venligst passende registeringsdata i request body."
|
|
35
|
+
validate_account_update_params: "Angiv venligst en passende konto opdatering i request body."
|
|
36
|
+
not_email: "er ikke en email"
|
|
37
|
+
devise:
|
|
38
|
+
mailer:
|
|
39
|
+
confirmation_instructions:
|
|
40
|
+
confirm_link_msg: "Du kan bekræfte din kontos email gennem linket herunder:"
|
|
41
|
+
confirm_account_link: "Bekræft min konto"
|
|
42
|
+
reset_password_instructions:
|
|
43
|
+
request_reset_link_msg: "Nogen har anmodet om et link til at ændre dit kodeord. Det kan du gøre via linket nedenfor."
|
|
44
|
+
password_change_link: "Skift mit kodeord."
|
|
45
|
+
ignore_mail_msg: "Hvis du ikke anmodede om dette, ignorer venligst denne email."
|
|
46
|
+
no_changes_msg: "Dit kodeord ændres først når du følger linket ovenfor og skaber et nyt."
|
|
47
|
+
unlock_instructions:
|
|
48
|
+
account_lock_msg: "Din konto er blevet låst fordi der har været for mange ugyldige log ind-forsøg."
|
|
49
|
+
unlock_link_msg: "Klik linket nedenfor, for at låse din konto op:"
|
|
50
|
+
unlock_link: "Lås min konto op"
|
|
51
|
+
hello: "hej"
|
|
52
|
+
welcome: "velkommen"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
de:
|
|
2
|
+
devise_jwt_auth:
|
|
3
|
+
sessions:
|
|
4
|
+
not_confirmed: "Eine Bestätigungs-E-Mail wurde an Ihre Adresse '%{email}' gesendet. Sie müssen der Anleitung in der E-Mail folgen, um Ihren Account zu aktivieren."
|
|
5
|
+
bad_credentials: "Ungültige Anmeldeinformationen. Bitte versuchen Sie es erneut."
|
|
6
|
+
not_supported: "Verwenden Sie POST /sign_in zur Anmeldung. GET wird nicht unterstützt."
|
|
7
|
+
user_not_found: "Benutzer wurde nicht gefunden oder konnte nicht angemeldet werden."
|
|
8
|
+
token_validations:
|
|
9
|
+
invalid: "Ungültige Anmeldeinformationen"
|
|
10
|
+
registrations:
|
|
11
|
+
missing_confirm_success_url: "Fehlender Paramter 'confirm_success_url'."
|
|
12
|
+
redirect_url_not_allowed: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
|
|
13
|
+
email_already_exists: "Es gibt bereits einen Account für '%{email}'."
|
|
14
|
+
account_with_uid_destroyed: "Account mit der uid '%{uid}' wurde gelöscht."
|
|
15
|
+
account_to_destroy_not_found: "Der zu löschende Account kann nicht gefunden werden."
|
|
16
|
+
user_not_found: "Benutzer kann nicht gefunden werden."
|
|
17
|
+
omniauth:
|
|
18
|
+
not_allowed_redirect_url: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
|
|
19
|
+
passwords:
|
|
20
|
+
missing_email: "Sie müssen eine E-Mail-Adresse angeben."
|
|
21
|
+
missing_redirect_url: "Es fehlt die URL zu Weiterleitung."
|
|
22
|
+
not_allowed_redirect_url: "Weiterleitung zu '%{redirect_url}' ist nicht gestattet."
|
|
23
|
+
sended: "Ein E-Mail mit der Anleitung zum Zurücksetzen Ihres Passwortes wurde an '%{email}' gesendet."
|
|
24
|
+
user_not_found: "Der Benutzer mit der E-Mail-Adresse '%{email}' kann nicht gefunden werden."
|
|
25
|
+
password_not_required: "Dieser Account benötigt kein Passwort. Melden Sie sich stattdessen über Ihren Account bei '%{provider}' an."
|
|
26
|
+
missing_passwords: "Sie müssen die Felder 'Passwort' und 'Passwortbestätigung' ausfüllen."
|
|
27
|
+
successfully_updated: "Ihr Passwort wurde erfolgreich aktualisiert."
|
|
28
|
+
errors:
|
|
29
|
+
messages:
|
|
30
|
+
validate_sign_up_params: "Bitte übermitteln sie vollständige Anmeldeinformationen im Body des Requests."
|
|
31
|
+
validate_account_update_params: "Bitte übermitteln sie vollständige Informationen zur Aktualisierung im Body des Requests."
|
|
32
|
+
not_email: "ist keine E-Mail-Adresse"
|
|
33
|
+
devise:
|
|
34
|
+
mailer:
|
|
35
|
+
confirmation_instructions:
|
|
36
|
+
subject: "Bestätigung Ihres Kontos"
|
|
37
|
+
confirm_link_msg: "Sie können Ihr Konto über den untenstehenden Link bestätigen:"
|
|
38
|
+
confirm_account_link: "Konto bestätigen"
|
|
39
|
+
reset_password_instructions:
|
|
40
|
+
subject: "Passwort zurücksetzen"
|
|
41
|
+
request_reset_link_msg: "Jemand hat einen Link zur Änderungen Ihres Passwortes angefordert. Sie können dies durch den folgenden Link tun:"
|
|
42
|
+
password_change_link: "Passwort ändern"
|
|
43
|
+
ignore_mail_msg: "Wenn Sie keine Änderung Ihres Passwortes angefordert haben, ignorieren Sie bitte diese E-Mail:"
|
|
44
|
+
no_changes_msg: "Ihr Passwort wird nicht geändert, bis Sie auf den obigen Link zugreifen und eine neues Passwort erstellen."
|
|
45
|
+
unlock_instructions:
|
|
46
|
+
subject: "Anweisungen zum Entsperren Ihres Kontos"
|
|
47
|
+
account_lock_msg: "Ihr Konto wurde aufgrund einer übermäßigen Anzahl von erfolglosen Anmeldeversuchen gesperrt."
|
|
48
|
+
unlock_link_msg: "Klicken Sie auf den Link unten, um Ihr Konto zu entsperren:"
|
|
49
|
+
unlock_link: "Entsperren Sie Ihr Konto"
|
|
50
|
+
hello: "hallo"
|
|
51
|
+
welcome: "willkommen"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
en:
|
|
2
|
+
devise_jwt_auth:
|
|
3
|
+
sessions:
|
|
4
|
+
not_confirmed: "A confirmation email was sent to your account at '%{email}'. You must follow the instructions in the email before your account can be activated"
|
|
5
|
+
bad_credentials: "Invalid login credentials. Please try again."
|
|
6
|
+
not_supported: "Use POST /sign_in to sign in. GET is not supported."
|
|
7
|
+
user_not_found: "User was not found or was not logged in."
|
|
8
|
+
token_validations:
|
|
9
|
+
invalid: "Invalid login credentials"
|
|
10
|
+
registrations:
|
|
11
|
+
missing_confirm_success_url: "Missing 'confirm_success_url' parameter."
|
|
12
|
+
redirect_url_not_allowed: "Redirect to '%{redirect_url}' not allowed."
|
|
13
|
+
email_already_exists: "An account already exists for '%{email}'"
|
|
14
|
+
account_with_uid_destroyed: "Account with UID '%{uid}' has been destroyed."
|
|
15
|
+
account_to_destroy_not_found: "Unable to locate account for destruction."
|
|
16
|
+
user_not_found: "User not found."
|
|
17
|
+
omniauth:
|
|
18
|
+
not_allowed_redirect_url: "Redirect to '%{redirect_url}' not allowed."
|
|
19
|
+
passwords:
|
|
20
|
+
missing_email: "You must provide an email address."
|
|
21
|
+
missing_redirect_url: "Missing redirect URL."
|
|
22
|
+
not_allowed_redirect_url: "Redirect to '%{redirect_url}' not allowed."
|
|
23
|
+
sended: "An email has been sent to '%{email}' containing instructions for resetting your password."
|
|
24
|
+
user_not_found: "Unable to find user with email '%{email}'."
|
|
25
|
+
password_not_required: "This account does not require a password. Sign in using your '%{provider}' account instead."
|
|
26
|
+
missing_passwords: "You must fill out the fields labeled 'Password' and 'Password confirmation'."
|
|
27
|
+
successfully_updated: "Your password has been successfully updated."
|
|
28
|
+
unlocks:
|
|
29
|
+
missing_email: "You must provide an email address."
|
|
30
|
+
sended: "An email has been sent to '%{email}' containing instructions for unlocking your account."
|
|
31
|
+
user_not_found: "Unable to find user with email '%{email}'."
|
|
32
|
+
confirmations:
|
|
33
|
+
sended: "An email has been sent to '%{email}' containing instructions for confirming your account."
|
|
34
|
+
user_not_found: "Unable to find user with email '%{email}'."
|
|
35
|
+
missing_email: "You must provide an email address."
|
|
36
|
+
|
|
37
|
+
errors:
|
|
38
|
+
messages:
|
|
39
|
+
validate_sign_up_params: "Please submit proper sign up data in request body."
|
|
40
|
+
validate_account_update_params: "Please submit proper account update data in request body."
|
|
41
|
+
not_email: "is not an email"
|
|
42
|
+
devise:
|
|
43
|
+
mailer:
|
|
44
|
+
confirmation_instructions:
|
|
45
|
+
confirm_link_msg: "You can confirm your account email through the link below:"
|
|
46
|
+
confirm_account_link: "Confirm my account"
|
|
47
|
+
reset_password_instructions:
|
|
48
|
+
request_reset_link_msg: "Someone has requested a link to change your password. You can do this through the link below."
|
|
49
|
+
password_change_link: "Change my password"
|
|
50
|
+
ignore_mail_msg: "If you didn't request this, please ignore this email."
|
|
51
|
+
no_changes_msg: "Your password won't change until you access the link above and create a new one."
|
|
52
|
+
unlock_instructions:
|
|
53
|
+
account_lock_msg: "Your account has been locked due to an excessive number of unsuccessful sign in attempts."
|
|
54
|
+
unlock_link_msg: "Click the link below to unlock your account:"
|
|
55
|
+
unlock_link: "Unlock my account"
|
|
56
|
+
hello: "hello"
|
|
57
|
+
welcome: "welcome"
|