anadea-identity 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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +174 -0
  4. data/Rakefile +10 -0
  5. data/app/assets/images/facebook.png +0 -0
  6. data/app/assets/images/google_oauth2.png +0 -0
  7. data/app/assets/images/twitter.png +0 -0
  8. data/app/controllers/identity/base_controller.rb +5 -0
  9. data/app/controllers/identity/omniauth_callbacks_controller.rb +24 -0
  10. data/app/controllers/identity/users_controller.rb +58 -0
  11. data/app/models/identity/role.rb +16 -0
  12. data/app/models/identity/user.rb +47 -0
  13. data/app/views/devise/confirmations/new.html.erb +23 -0
  14. data/app/views/devise/mailer/confirmation_instructions.html.erb +6 -0
  15. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  16. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  17. data/app/views/devise/passwords/edit.html.erb +28 -0
  18. data/app/views/devise/passwords/new.html.erb +21 -0
  19. data/app/views/devise/registrations/edit.html.erb +34 -0
  20. data/app/views/devise/registrations/new.html.erb +28 -0
  21. data/app/views/devise/sessions/new.html.erb +31 -0
  22. data/app/views/devise/shared/_links.erb +25 -0
  23. data/app/views/devise/unlocks/new.html.erb +20 -0
  24. data/app/views/identity/users/edit.html.erb +70 -0
  25. data/app/views/identity/users/index.html.erb +55 -0
  26. data/config/locales/ca.yml +59 -0
  27. data/config/locales/de.yml +110 -0
  28. data/config/locales/en.yml +111 -0
  29. data/config/locales/es-AR.yml +51 -0
  30. data/config/locales/es-ES.yml +59 -0
  31. data/config/locales/es.yml +51 -0
  32. data/config/locales/fr.yml +51 -0
  33. data/config/locales/hu.yml +59 -0
  34. data/config/locales/it.yml +51 -0
  35. data/config/locales/nl.yml +59 -0
  36. data/config/locales/pl.yml +57 -0
  37. data/config/locales/pt-BR.yml +51 -0
  38. data/config/locales/ru.yml +56 -0
  39. data/config/locales/tr.yml +51 -0
  40. data/config/locales/zh-CN.yml +57 -0
  41. data/config/locales/zh-TW.yml +57 -0
  42. data/config/routes.rb +5 -0
  43. data/db/migrate/20150402142437_devise_create_identity_users.rb +42 -0
  44. data/db/migrate/20150402152859_rolify_create_identity_roles.rb +19 -0
  45. data/lib/anadea/identity.rb +1 -0
  46. data/lib/generators/identity/locales_generator.rb +8 -0
  47. data/lib/generators/identity/views_generator.rb +8 -0
  48. data/lib/identity.rb +50 -0
  49. data/lib/identity/admin/user.rb +89 -0
  50. data/lib/identity/devise_config.rb +31 -0
  51. data/lib/identity/engine.rb +21 -0
  52. data/lib/identity/version.rb +3 -0
  53. data/lib/identity/view_helper.rb +22 -0
  54. data/lib/tasks/whoami_tasks.rake +4 -0
  55. metadata +157 -0
@@ -0,0 +1,57 @@
1
+ pl:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: Wyślij ponownie instrukcje aktywacji
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: Potwierdź swoje konto
9
+ greeting: Witaj %{recipient}!
10
+ instruction: ! 'Możesz potwierdzić swoje konto przy pomocy poniższego linku:'
11
+ subject: Instrukcja aktywacji konta
12
+ reset_password_instructions:
13
+ action: Zmień swoje hasło
14
+ greeting: Cześć %{recipient}!
15
+ instruction: 'Ktoś zażądał zmiany hasła do Twojego konta. Hasło możesz zmienić wchodząc na poniższy link:'
16
+ instruction_2: Jeśli to nie Ty zażądałeś zmiany hasła, proszę zignoruj tę wiadomość.
17
+ instruction_3: Twoje hasło nie ulegnie zmianie dopóki nie wejdziesz na poniższy link i nie ustawisz nowego.
18
+ subject: Instrukcja zmiany hasła
19
+ unlock_instructions:
20
+ action: Odblokuj swoje konto
21
+ greeting: Cześć %{recipient}!
22
+ instruction: ! 'Kliknij poniższy link aby odblokować swoje konto.'
23
+ message: Twoje konto zostało zablokowane z powodu zbyt dużej ilości nieprawidłowych prób zalogowania się na nie.
24
+ subject: Instrukcja odblokowania konta
25
+ passwords:
26
+ new:
27
+ forgot_your_password: Zapomniałeś swoje hasło?
28
+ send_me_reset_password_instructions: Wyślij instrukcje zmiany hasła
29
+ edit:
30
+ change_your_password: Zmień swoje hasło
31
+ new_password: Nowe hasło
32
+ confirm_new_password: Powtórz nowe hasło
33
+ change_my_password: Zmień swoje hasło
34
+ registrations:
35
+ edit:
36
+ are_you_sure: Jesteś pewny?
37
+ cancel_my_account: Anuluj moje konto
38
+ leave_blank_if_you_don_t_want_to_change_it: pozostaw puste jeśli nie chcesz wprowadzać zmian
39
+ title: Edytuj %{resource}
40
+ we_need_your_current_password_to_confirm_your_changes: potrzebujemy Twojego bieżącego hasła aby potwierdzić zmiany
41
+ update: Zaktualizuj
42
+ new:
43
+ sign_up: Zarejestruj się
44
+ sessions:
45
+ new:
46
+ sign_in: Zaloguj się
47
+ shared:
48
+ links:
49
+ didn_t_receive_confirmation_instructions: Nie otrzymałeś instrukcji aktywacji konta?
50
+ didn_t_receive_unlock_instructions: Nie otrzymałeś instrukcji odblokowania konta?
51
+ forgot_your_password: Zapomniałeś hasło?
52
+ sign_in: Zaloguj się
53
+ sign_in_with_provider: Zaloguj się przez %{provider}
54
+ sign_up: Zarejestruj się
55
+ unlocks:
56
+ new:
57
+ resend_unlock_instructions: Wyślij instrukcje odblokowania konta
@@ -0,0 +1,51 @@
1
+ pt-BR:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: Reenviar instruções de confirmação
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: Confirmar minha conta
9
+ greeting: Bem-vindo %{recipient}!
10
+ instruction: ! 'Você pode confirmar sua conta através do link abaixo:'
11
+ subject: Instruções de confirmação
12
+ reset_password_instructions:
13
+ action: Redefinir minha senha
14
+ greeting: Olá %{recipient}!
15
+ instruction: Alguém fez o pedido para redefinir sua senha, e você pode fazer isso clicando no link abaixo.
16
+ instruction_2: Se você não fez este pedido, por favor ignore este e-mail.
17
+ instruction_3: Sua senha não será alterada até que você acesse o link abaixo e crie uma nova.
18
+ subject: Instruções para redefinição da senha
19
+ unlock_instructions:
20
+ action: Desbloquear minha conta
21
+ greeting: Olá %{recipient}!
22
+ instruction: ! 'Clique no link abaixo para desbloquear sua conta:'
23
+ message: Sua conta foi bloqueada devido ao excessivo número de tentativas acesso inválidas.
24
+ subject: Instruções de desbloqueio
25
+ passwords:
26
+ new:
27
+ forgot_your_password: Esqueceu sua senha?
28
+ send_me_reset_password_instructions: Enviar instruções para redefinição da senha
29
+ registrations:
30
+ edit:
31
+ are_you_sure: Você tem certeza?
32
+ cancel_my_account: Cancelar minha conta
33
+ leave_blank_if_you_don_t_want_to_change_it: deixe em branco caso não queira alterá-la
34
+ title: Editar %{resource}
35
+ we_need_your_current_password_to_confirm_your_changes: precisamos da sua senha atual para confirmar suas mudanças
36
+ new:
37
+ sign_up: Inscrever-se
38
+ sessions:
39
+ new:
40
+ sign_in: Login
41
+ shared:
42
+ links:
43
+ didn_t_receive_confirmation_instructions: Não recebeu instruções de confirmação?
44
+ didn_t_receive_unlock_instructions: Não recebeu instruções de desbloqueio?
45
+ forgot_your_password: Equeceu sua senha?
46
+ sign_in: Login
47
+ sign_in_with_provider: Entrar com %{provider}
48
+ sign_up: Inscrever-se
49
+ unlocks:
50
+ new:
51
+ resend_unlock_instructions: Renviar instruções de desbloqueio
@@ -0,0 +1,56 @@
1
+ ru:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: Выслать повторно письмо с активацией
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: Активировать
9
+ greeting: Привет %{recipient}!
10
+ instruction: ! 'Вы можете активировать свою учетную запись, нажав ссылку снизу:'
11
+ subject: Активация учетной записи
12
+ reset_password_instructions:
13
+ action: Изменить пароль
14
+ greeting: Привет %{recipient}!
15
+ instruction: ! 'Вы (или кто-то еще) запросили изменение пароля. Для изменение пароля нажимите ссылку ниже:'
16
+ instruction_2: Если вы не запрашивали изменение пароля - проигнорируйте это сообщение
17
+ instruction_3: Ваш пароль не изменится пока вы не нажмете на ссылку и не введете новый.
18
+ subject: Запрос на изменение пароля
19
+ unlock_instructions:
20
+ action: Разблокировать учетную запись
21
+ greeting: Привет %{recipient}!
22
+ instruction: ! 'Нажмите ссылку для активации учетной записи:'
23
+ message: Ваша учетная запись была заблокирована в связи с превышением лимита неудачных попыток входа.
24
+ subject: Инструкции для разблокировки учетной записи
25
+ passwords:
26
+ new:
27
+ forgot_your_password: Забыли пароль?
28
+ send_me_reset_password_instructions: Выслать новый пароль
29
+ edit:
30
+ change_your_password: Изменить пароль
31
+ new_password: Новый пароль
32
+ confirm_new_password: Повторите новый пароль
33
+ change_my_password: Изменить мой пароль
34
+ registrations:
35
+ edit:
36
+ are_you_sure: Вы уверены?
37
+ cancel_my_account: Удалить учетную запись
38
+ leave_blank_if_you_don_t_want_to_change_it: оставьте поле пустым, если не хотите ничего менять
39
+ title: Редактировать %{resource}
40
+ we_need_your_current_password_to_confirm_your_changes: введите текущий пароль для подтверждения изменений
41
+ new:
42
+ sign_up: Регистрация
43
+ sessions:
44
+ new:
45
+ sign_in: Войти
46
+ shared:
47
+ links:
48
+ didn_t_receive_confirmation_instructions: Не получили подтверждение?
49
+ didn_t_receive_unlock_instructions: Не получили код разблокировки?
50
+ forgot_your_password: Забыли пароль?
51
+ sign_in: Войти
52
+ sign_in_with_provider: ! 'Войти с помощью: %{provider}'
53
+ sign_up: Регистрация
54
+ unlocks:
55
+ new:
56
+ resend_unlock_instructions: Выслать подтверждение заново
@@ -0,0 +1,51 @@
1
+ tr:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: Onaylama talimatlarını tekrar gönder
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: Hesabımı onayla
9
+ greeting: Hoşgeldiniz %{recipient}!
10
+ instruction: ! 'E-postanızı aşağıdaki bağlantıyı takip ederek onaylayabilirsiniz:'
11
+ subject: Onaylama talimatları
12
+ reset_password_instructions:
13
+ action: Parolamı değiştir
14
+ greeting: Merhaba %{recipient}!
15
+ instruction: Birisi parolanızı değiştirmek için bir istek gönderdi, aşağıdaki bağlantıyı kullanarak bunu yapabilirsiniz.
16
+ instruction_2: Eğer bu isteği siz yapmadıysanız, bu e-postayı görmezden gelebilirsiniz.
17
+ instruction_3: Parolanız yukarıdaki bağlantıyı kullanıp, yeni bir parola oluşturmadığınız sürece değişmeyecektir.
18
+ subject: Parola yenileme talimatları
19
+ unlock_instructions:
20
+ action: Hesabımı geri aç
21
+ greeting: Merhaba %{recipient}!
22
+ instruction: ! 'Hesabınızı geri açmak için aşağıdaki bağlantıyı tıklayınız:'
23
+ message: Hesabınız çok fazla başarısız giriş denemesinden dolayı kilitlenmiştir.
24
+ subject: Hesap geri açma talimatları
25
+ passwords:
26
+ new:
27
+ forgot_your_password: Parolanızı mı unuttunuz?
28
+ send_me_reset_password_instructions: Parola yenileme talimatlarını gönder
29
+ registrations:
30
+ edit:
31
+ are_you_sure: Emin misiniz?
32
+ cancel_my_account: Hesabımı iptal et
33
+ leave_blank_if_you_don_t_want_to_change_it: değiştirmek istemiyorsanız boş bırakın
34
+ title: ! '%{resource} düzenle'
35
+ we_need_your_current_password_to_confirm_your_changes: değişikleri onaylamak için şu anki parolanız gerekli
36
+ new:
37
+ sign_up: Kaydol
38
+ sessions:
39
+ new:
40
+ sign_in: Giriş yap
41
+ shared:
42
+ links:
43
+ didn_t_receive_confirmation_instructions: Onaylama talimatlarını almadınız mı?
44
+ didn_t_receive_unlock_instructions: Hesap geri açma talimatlarını almadınız mı?
45
+ forgot_your_password: Parolanızı mı unuttunuz?
46
+ sign_in: Giriş yap
47
+ sign_in_with_provider: ! '%{provider} ile giriş yap'
48
+ sign_up: Kaydol
49
+ unlocks:
50
+ new:
51
+ resend_unlock_instructions: Hesap geri açma talimatlarını tekrar gönder
@@ -0,0 +1,57 @@
1
+ zh-CN:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: 重新发送确认指示
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: 确认我的帐户
9
+ greeting: 欢迎 %{recipient}!
10
+ instruction: ! '您可以通过下面的链接确认您的帐户的电子邮件:'
11
+ subject: 确认指示
12
+ reset_password_instructions:
13
+ action: 更改我的密码
14
+ greeting: 你好 %{recipient}!
15
+ instruction: 有人要求更改密码的链接,并通过下面的链接,你可以做到这一点。
16
+ instruction_2: 如果你没有要求,请忽略此电子邮件。
17
+ instruction_3: 您的密码将不会改变,直到你访问上面的链接,并创建一个新的。
18
+ subject: 重设密码的说明
19
+ unlock_instructions:
20
+ action: 帐户解锁
21
+ greeting: 你好 %{recipient}!
22
+ instruction: ! '点击下面的链接到您的帐户解锁:'
23
+ message: 您的帐户已被锁定由于过量的不成功的登录尝试。
24
+ subject: 解锁说明
25
+ passwords:
26
+ new:
27
+ forgot_your_password: 忘记密码?
28
+ send_me_reset_password_instructions: 给我发送重设密码的说明
29
+ edit:
30
+ change_your_password: 更改您的密码
31
+ new_password: 新密码
32
+ confirm_new_password: 确认新密码
33
+ change_my_password: 更改我的密码
34
+ registrations:
35
+ edit:
36
+ are_you_sure: 你确定吗?
37
+ cancel_my_account: 取消我的帐户
38
+ leave_blank_if_you_don_t_want_to_change_it: 你不想去改变它,不需要填写
39
+ title: 修改 %{resource}
40
+ we_need_your_current_password_to_confirm_your_changes: 我们需要您的当前密码以确认您的更改
41
+ update: 更新
42
+ new:
43
+ sign_up: 注册
44
+ sessions:
45
+ new:
46
+ sign_in: 登录
47
+ shared:
48
+ links:
49
+ didn_t_receive_confirmation_instructions: 没有收到确认指令?
50
+ didn_t_receive_unlock_instructions: 没有收到解锁指令?
51
+ forgot_your_password: 忘记密码?
52
+ sign_in: 登录
53
+ sign_in_with_provider: 用 %{provider} 登录
54
+ sign_up: 注册
55
+ unlocks:
56
+ new:
57
+ resend_unlock_instructions: 重发解锁指示
@@ -0,0 +1,57 @@
1
+ zh-TW:
2
+ devise:
3
+ confirmations:
4
+ new:
5
+ resend_confirmation_instructions: '重新發送確認信'
6
+ mailer:
7
+ confirmation_instructions:
8
+ action: '確認帳號'
9
+ greeting: '%{recipient} 你好!'
10
+ instruction: ! '您可以利用下面的連結確認您的帳戶的電子郵件:'
11
+ subject: '確認帳號的說明'
12
+ reset_password_instructions:
13
+ action: '更改我的密碼'
14
+ greeting: '你好 %{recipient}!'
15
+ instruction: '有人要求更改密碼的連結,你可以利用下面的連結更改密碼。'
16
+ instruction_2: '如果你沒有要求,請忽略此電子郵件。'
17
+ instruction_3: '如果你沒有進入上面的連結,並建立新的密碼,你的密碼不會被改變。'
18
+ subject: '重設密碼的說明'
19
+ unlock_instructions:
20
+ action: '帳戶解鎖'
21
+ greeting: '你好 %{recipient}!'
22
+ instruction: ! '點擊下面的連結到您的帳戶進行解鎖:'
23
+ message: '由於多次的不成功的登入嘗試,您的帳戶已被鎖定。'
24
+ subject: '帳戶解鎖說明'
25
+ passwords:
26
+ new:
27
+ forgot_your_password: '忘記密碼?'
28
+ send_me_reset_password_instructions: '請寄重設密碼的說明信件給我'
29
+ edit:
30
+ change_your_password: '更改您的密碼'
31
+ new_password: '新密碼'
32
+ confirm_new_password: '確認新密碼'
33
+ change_my_password: '更改我的密碼'
34
+ registrations:
35
+ edit:
36
+ are_you_sure: '你確定嗎?'
37
+ cancel_my_account: '取消我的帳戶'
38
+ leave_blank_if_you_don_t_want_to_change_it: '不想修改的話就不需要填寫這個欄位'
39
+ title: '修改 %{resource}'
40
+ we_need_your_current_password_to_confirm_your_changes: '我們需要您的目前的密碼以確認您的更改'
41
+ update: '更新'
42
+ new:
43
+ sign_up: '註冊'
44
+ sessions:
45
+ new:
46
+ sign_in: '登入'
47
+ shared:
48
+ links:
49
+ didn_t_receive_confirmation_instructions: '沒有收到確認信件?'
50
+ didn_t_receive_unlock_instructions: '沒有收到解鎖信件?'
51
+ forgot_your_password: '忘記密碼?'
52
+ sign_in: '登入'
53
+ sign_in_with_provider: '用 %{provider} 登入'
54
+ sign_up: '註冊'
55
+ unlocks:
56
+ new:
57
+ resend_unlock_instructions: '重發解鎖說明信件'
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ if Identity.auth_routes
3
+ devise_for :users, class_name: "Identity::User", module: :devise, :controllers => { :omniauth_callbacks => "identity/omniauth_callbacks" }
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ class DeviseCreateIdentityUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:identity_users) do |t|
4
+ # To enable/disable users from admin area
5
+ t.boolean :active, null: false, default: true
6
+
7
+ ## Database authenticatable
8
+ t.string :email, null: false, default: ""
9
+ t.string :encrypted_password, null: false, default: ""
10
+
11
+ ## Recoverable
12
+ t.string :reset_password_token
13
+ t.datetime :reset_password_sent_at
14
+
15
+ ## Rememberable
16
+ t.datetime :remember_created_at
17
+
18
+ ## Trackable
19
+ t.integer :sign_in_count, default: 0, null: false
20
+ t.datetime :current_sign_in_at
21
+ t.datetime :last_sign_in_at
22
+ t.string :current_sign_in_ip
23
+ t.string :last_sign_in_ip
24
+
25
+ ## Confirmable
26
+ t.string :confirmation_token
27
+ t.datetime :confirmed_at
28
+ t.datetime :confirmation_sent_at
29
+ t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Omniauthable
32
+ t.string :provider
33
+ t.string :uid
34
+
35
+ t.timestamps null: true
36
+ end
37
+
38
+ add_index :identity_users, :email, unique: true
39
+ add_index :identity_users, :reset_password_token, unique: true
40
+ add_index :identity_users, :confirmation_token, unique: true
41
+ end
42
+ end
@@ -0,0 +1,19 @@
1
+ class RolifyCreateIdentityRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table(:identity_roles) do |t|
4
+ t.string :name
5
+ t.references :resource, :polymorphic => true
6
+
7
+ t.timestamps null: true
8
+ end
9
+
10
+ create_table(:identity_users_identity_roles, :id => false) do |t|
11
+ t.references :user
12
+ t.references :role
13
+ end
14
+
15
+ add_index(:identity_roles, :name)
16
+ add_index(:identity_roles, [ :name, :resource_type, :resource_id ])
17
+ add_index(:identity_users_identity_roles, [ :user_id, :role_id ])
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ require_relative "../identity"
@@ -0,0 +1,8 @@
1
+ module Identity
2
+ class LocalesGenerator < Rails::Generators::NamedBase
3
+ source_root File.expand_path('../../../../config/locales', __FILE__)
4
+ def copy_locale
5
+ copy_file("#{name}.yml", Rails.root.join("config", "locales", "whoami.views.#{name}.yml"))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Identity
2
+ class ViewsGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../app/views', __FILE__)
4
+ def copy_views
5
+ directory("devise", Rails.root.join("app", "views", "devise"))
6
+ end
7
+ end
8
+ end
data/lib/identity.rb ADDED
@@ -0,0 +1,50 @@
1
+ require "identity/engine"
2
+
3
+
4
+ module Identity
5
+ mattr_accessor :devise_modules do
6
+ [
7
+ :database_authenticatable,
8
+ :registerable,
9
+ :recoverable,
10
+ :rememberable,
11
+ :trackable,
12
+ :validatable
13
+ ]
14
+ end
15
+
16
+ mattr_accessor(:layout) { 'application' }
17
+ mattr_accessor(:auth_routes) { true }
18
+ mattr_accessor(:admin_namespace) { :identity }
19
+ mattr_accessor(:admin_role) { :admin }
20
+
21
+ def self.admins_method
22
+ :"#{admin_role.to_s.pluralize}"
23
+ end
24
+
25
+ def self.admin_predicate
26
+ :"#{admin_role}?"
27
+ end
28
+
29
+ def self.setup
30
+ yield self
31
+ end
32
+
33
+ def self.method_missing(name, *args, &block)
34
+ if delegate_to_devise?(name.to_s)
35
+ Devise.public_send(name, *args, &block)
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ def self.delegate_to_devise?(name)
42
+ name.in? %w(omniauth) ||
43
+ name.ends_with?('=') && Devise.respond_to?(name)
44
+ end
45
+
46
+ def self.respond_to_missing?(name, include_private = false)
47
+ (name.to_s.ends_with?('=') && Devise.respond_to?(name, include_private)) || super
48
+ end
49
+
50
+ end