aerogel-users 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +16 -0
  6. data/Rakefile +1 -0
  7. data/aerogel-users.gemspec +30 -0
  8. data/app/helpers/access_control.rb +32 -0
  9. data/app/helpers/auth.rb +58 -0
  10. data/app/helpers/auth_login_providers.rb +18 -0
  11. data/app/mailers/user.rb +43 -0
  12. data/app/routes/access_control.rb +15 -0
  13. data/app/routes/auth.rb +53 -0
  14. data/app/routes/user.rb +192 -0
  15. data/assets/README.md +1 -0
  16. data/assets/javascripts/.gitkeep +0 -0
  17. data/assets/stylesheets/.gitkeep +0 -0
  18. data/config/auth.conf +43 -0
  19. data/config/development/.keep +0 -0
  20. data/config/production/.keep +0 -0
  21. data/db/model/access.rb +67 -0
  22. data/db/model/authentication.rb +54 -0
  23. data/db/model/role.rb +17 -0
  24. data/db/model/user.rb +223 -0
  25. data/db/model/user_email.rb +24 -0
  26. data/db/model/user_registration_form.rb +23 -0
  27. data/db/model/user_request_account_activation_form.rb +30 -0
  28. data/db/model/user_request_email_confirmation_form.rb +40 -0
  29. data/db/model/user_request_password_reset_form.rb +37 -0
  30. data/db/model/user_reset_password_form.rb +41 -0
  31. data/db/seed/01_user_role.seed +8 -0
  32. data/db/seed/02_access_user.seed +25 -0
  33. data/db/seed/development/.keep +0 -0
  34. data/db/seed/development/test-user.seed +77 -0
  35. data/db/seed/production/.keep +0 -0
  36. data/lib/aerogel/users.rb +22 -0
  37. data/lib/aerogel/users/auth.rb +67 -0
  38. data/lib/aerogel/users/omniauth-failure_endpoint_ex.rb +21 -0
  39. data/lib/aerogel/users/omniauth-password.rb +63 -0
  40. data/lib/aerogel/users/secure_password.rb +55 -0
  41. data/lib/aerogel/users/version.rb +5 -0
  42. data/locales/actions/en.yml +18 -0
  43. data/locales/actions/ru.yml +17 -0
  44. data/locales/auth/en.yml +22 -0
  45. data/locales/auth/ru.yml +22 -0
  46. data/locales/mailers/en.yml +69 -0
  47. data/locales/mailers/ru.yml +73 -0
  48. data/locales/models/en.yml +65 -0
  49. data/locales/models/ru.yml +64 -0
  50. data/locales/views/en.yml +122 -0
  51. data/locales/views/ru.yml +126 -0
  52. data/public/README.md +1 -0
  53. data/rake/README.md +3 -0
  54. data/views/mailers/user/account_activation.html.erb +3 -0
  55. data/views/mailers/user/account_activation.text.erb +3 -0
  56. data/views/mailers/user/email_confirmation.html.erb +3 -0
  57. data/views/mailers/user/email_confirmation.text.erb +3 -0
  58. data/views/mailers/user/password_reset.html.erb +3 -0
  59. data/views/mailers/user/password_reset.text.erb +3 -0
  60. data/views/user/activate_account.html.erb +3 -0
  61. data/views/user/activate_account_failure.html.erb +3 -0
  62. data/views/user/confirm_email.html.erb +3 -0
  63. data/views/user/confirm_email_failure.html.erb +3 -0
  64. data/views/user/edit.html.erb +6 -0
  65. data/views/user/index.html.erb +19 -0
  66. data/views/user/login.html.erb +3 -0
  67. data/views/user/login/_form.html.erb +28 -0
  68. data/views/user/login/_provider.html.erb +5 -0
  69. data/views/user/logout.html.erb +3 -0
  70. data/views/user/register.html.erb +10 -0
  71. data/views/user/register_success.html.erb +3 -0
  72. data/views/user/request_account_activation.html.erb +9 -0
  73. data/views/user/request_account_activation_success.html.erb +3 -0
  74. data/views/user/request_email_confirmation.html.erb +8 -0
  75. data/views/user/request_email_confirmation_success.html.erb +3 -0
  76. data/views/user/request_password_reset.html.erb +8 -0
  77. data/views/user/request_password_reset_success.html.erb +3 -0
  78. data/views/user/reset_password.html.erb +9 -0
  79. data/views/user/reset_password_success.html.erb +3 -0
  80. metadata +234 -0
@@ -0,0 +1,55 @@
1
+ require 'bcrypt'
2
+
3
+ module Aerogel
4
+ module Db
5
+ module SecurePassword
6
+
7
+ include BCrypt
8
+
9
+ def self.included(base)
10
+ base.extend(ClassMethods)
11
+ end
12
+
13
+ module ClassMethods
14
+ def use_secure_password
15
+ attr_reader :password
16
+
17
+ field :password_digest, type: String
18
+
19
+ validates_presence_of :password, on: :create, if: :validate_password?
20
+ validates_confirmation_of :password, if: lambda { |r| r.password.present? }
21
+ validates_presence_of :password_confirmation, if: lambda { |r| r.password.present? }
22
+
23
+ if respond_to?(:attributes_protected_by_default)
24
+ def self.attributes_protected_by_default #:nodoc:
25
+ super + ['password_digest']
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+
33
+ def password=( new_password )
34
+ unless new_password.blank?
35
+ @password = new_password
36
+ self.password_digest = Password.create( new_password )
37
+ end
38
+ end
39
+
40
+ def password_confirmation=( new_password )
41
+ @password_confirmation = new_password
42
+ end
43
+
44
+ def password_is?( unencrypted_password )
45
+ Password.new(password_digest) == unencrypted_password
46
+ end
47
+
48
+ # If password should not be validated on each record,
49
+ # override this method to make it conditional.
50
+ #
51
+ def validate_password?; true; end
52
+
53
+ end # module SecurePassword
54
+ end # module Db
55
+ end # module Aerogel
@@ -0,0 +1,5 @@
1
+ module Aerogel
2
+ module Users
3
+ VERSION = "1.4.3"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ en:
2
+ aerogel:
3
+ auth:
4
+ actions:
5
+ access_denied: "Access denied to %{path} (%{access})"
6
+ users:
7
+ actions:
8
+ login: Log in
9
+ logged_in: Logged in
10
+ logout: Log out
11
+ logged_out: Logged out
12
+ edit: Edit account details
13
+ register: Create an account
14
+ registered: Account created
15
+ request_account_activation: Request account activation
16
+ request_email_confirmation: Request email confirmation message
17
+ request_password_reset: Request password reset
18
+
@@ -0,0 +1,17 @@
1
+ ru:
2
+ aerogel:
3
+ auth:
4
+ actions:
5
+ access_denied: "Запрещён доступ к %{path} (%{access})"
6
+ users:
7
+ actions:
8
+ login: Войти
9
+ logged_in: Вход выполнен
10
+ logout: Выйти
11
+ logged_out: Выход выполнен
12
+ edit: Редактировать учётную запись
13
+ register: Создать учётную запись
14
+ registered: Учётная запись создана
15
+ request_account_activation: Запросить активацию учётной записи
16
+ request_email_confirmation: Запросить подтвержение адреса email
17
+ request_password_reset: Запросить переустановку пароля
@@ -0,0 +1,22 @@
1
+ en:
2
+ aerogel:
3
+ auth:
4
+ welcome:
5
+ Welcome, %{full_name}!
6
+ welcome_new_user:
7
+ "Welcome, %{full_name}! Please review and update your details if necessary."
8
+
9
+ errors:
10
+ invalid_credentials:
11
+ "Failed to log in with %{provider} because of invalid credentials"
12
+ unknown:
13
+ "Failed to log in with %{provider}, unknown error: %{message}"
14
+ create_from_omniauth:
15
+ "Failed to register new user because of following errors: %{errors}"
16
+
17
+ password:
18
+ errors:
19
+ invalid_credentials:
20
+ Invalid user email or password
21
+ account_not_activated:
22
+ "Your account is not activated yet. Request <a href='/user/request_account_activation'>account activation</a> again."
@@ -0,0 +1,22 @@
1
+ ru:
2
+ aerogel:
3
+ auth:
4
+ welcome:
5
+ Добро пожаловать, %{full_name}!
6
+ welcome_new_user:
7
+ "Добро пожаловать, %{full_name}! Пожалуйста проверьте информацию о вас и исправьте если необходимо."
8
+
9
+ errors:
10
+ invalid_credentials:
11
+ "Не удалось выполнить вход с помощью %{provider} из-за отказа в доступе"
12
+ unknown:
13
+ "Не удалось выполнить вход с помощью %{provider}, неизвестная ошибка: %{message}"
14
+ create_from_omniauth:
15
+ "Не удалось зарегистрировать нового пользователя из-за следующих ошибок: %{errors}"
16
+
17
+ password:
18
+ errors:
19
+ invalid_credentials:
20
+ Неправильный email пользователя или пароль
21
+ account_not_activated:
22
+ "Ваша учётная запись ещё не активирована. Запросите <a href='/user/request_account_activation'>активацию учётной записи</a> ещё раз."
@@ -0,0 +1,69 @@
1
+ en:
2
+ aerogel:
3
+ users:
4
+ mailers:
5
+
6
+ account_activation:
7
+ subject: Activate your account
8
+ html:
9
+ title: "<h1>Welcome, %{full_name}!</h1>"
10
+ text: |
11
+ <p>
12
+ Your account is almost ready.
13
+ The only thing left is to confirm your email address by clicking
14
+ <a href="%{url}">this link</a>.
15
+ </p>
16
+ text:
17
+ title: "Welcome, %{full_name}!"
18
+ text: |
19
+ Your account is almost ready. The only thing left is to confirm your email address.
20
+ To do this, copy and paste the following URL into your browser's address bar and press Enter:
21
+
22
+ %{url}
23
+
24
+ email_confirmation:
25
+ subject: Confirm your email address
26
+ html:
27
+ title: "<h1>Hello, %{full_name}!</h1>"
28
+ text: |
29
+ <p>
30
+ Confirm your email address by clicking
31
+ <a href="%{url}">this link</a>.
32
+ </p>
33
+ text:
34
+ title: "Hello, %{full_name}!"
35
+ text: |
36
+ To confirm your email address, copy and paste the following URL
37
+ into your browser's address bar and press Enter:
38
+
39
+ %{url}
40
+
41
+ password_reset:
42
+ subject: Reset your password
43
+ html:
44
+ title: "<h1>Hello, %{full_name}!</h1>"
45
+ text: |
46
+ <p>
47
+ You have requested to reset your password. To do that visit
48
+ <a href="%{url}">this page</a>,
49
+ where you can set the password to a new one.
50
+ </p>
51
+ <p>
52
+ NOTE: If you haven't requested the password reset, log in to your account
53
+ using your current credentials and this request will be cancelled.
54
+ </p>
55
+
56
+ text:
57
+ title: "Hello, %{full_name}!"
58
+ text: |
59
+ You have requested to reset your password.
60
+ To do that, copy and paste the following URL into your browser's address bar and press Enter,
61
+ then you will be presented with a page where you can set the password to a new one:
62
+
63
+ %{url}
64
+
65
+ NOTE: If you haven't requested the password reset, log in to your account
66
+ using your current credentials and this request will be cancelled.
67
+
68
+
69
+
@@ -0,0 +1,73 @@
1
+ ru:
2
+ aerogel:
3
+ users:
4
+ mailers:
5
+
6
+ account_activation:
7
+ subject: Активируйте вашу учётную запись
8
+ html:
9
+ title: "<h1>Добро пожаловать, %{full_name}!</h1>"
10
+ text: |
11
+ <p>
12
+ Ваша учётная запись почти готова.
13
+ Осталось всего лишь подтвердить ваш email адрес, нажав
14
+ <a href="%{url}">эту ссылку</a>.
15
+ </p>
16
+ text:
17
+ title: "Добро пожаловать, %{full_name}!"
18
+ text: |
19
+ Ваша учётная запись почти готова.
20
+ Осталось всего лишь подтвердить ваш email адрес. Чтобы сделать это,
21
+ скопируйте следующий URL в адресную строку своего броузера и нажмите Enter:
22
+
23
+ %{url}
24
+
25
+ email_confirmation:
26
+ subject: Подтвердите ваш email адрес
27
+ html:
28
+ title: "<h1>Добрый день, %{full_name}!</h1>"
29
+ text: |
30
+ <p>
31
+ Подтвердите ваш email адрес, перейдя по
32
+ <a href="%{url}">этой ссылке</a>.
33
+ </p>
34
+ text:
35
+ title: "Добрый день, %{full_name}!"
36
+ text: |
37
+ Чтобы подтвердить ваш email адрес
38
+ скопируйте следующий URL в адресную строку своего броузера и нажмите Enter:
39
+
40
+ %{url}
41
+
42
+ password_reset:
43
+ subject: Переустановка пароля
44
+ html:
45
+ title: "<h1>Добрый день, %{full_name}!</h1>"
46
+ text: |
47
+ <p>
48
+ Вы запросили переустановку своего пароля. Чтобы сделать это,
49
+ перейдите на
50
+ <a href="%{url}">эту страницу</a>,
51
+ где вы сможете поменять пароль на новый.
52
+ </p>
53
+ <p>
54
+ ВНИМАНИЕ: Если вы не запрашивали переустановку пароля,
55
+ выполните вход на сайт с помощью существующих email и пароля,
56
+ и запрос на переустановку пароля будет отменён.
57
+ </p>
58
+
59
+ text:
60
+ title: "Добрый день, %{full_name}!"
61
+ text: |
62
+ Вы запросили переустановку своего пароля. Чтобы попасть на страницу,
63
+ где вы сможете поменять пароль на новый,
64
+ скопируйте следующий URL в адресную строку своего броузера и нажмите Enter:
65
+
66
+ %{url}
67
+
68
+ ВНИМАНИЕ: Если вы не запрашивали переустановку пароля,
69
+ выполните вход на сайт с помощью существующих email и пароля,
70
+ и запрос на переустановку пароля будет отменён.
71
+
72
+
73
+
@@ -0,0 +1,65 @@
1
+ en:
2
+ attributes:
3
+ created_at: "Created @"
4
+ updated_at: "Updated @"
5
+ email: "Email"
6
+ full_name: "Full name"
7
+ password: "Password"
8
+ password_confirmation: "Password confirmation"
9
+ name: "Name"
10
+ uid: "UID"
11
+ id: "ID"
12
+ slug: "Slug"
13
+
14
+
15
+ mongoid:
16
+ models:
17
+ access: Access
18
+ authentication: Authentication method
19
+ role: Role
20
+ user: User
21
+ user_email: User email
22
+ user_registration_form: User registration form
23
+ user_request_account_activation_form: Account activation request form
24
+ user_request_email_confirmation_form: Email confirmation request form
25
+ user_request_password_reset_form: Password reset request form
26
+ user_reset_password_form: Password reset form
27
+
28
+ attributes:
29
+ access:
30
+ path: Path
31
+ access: Access
32
+ role: Role
33
+ authentication:
34
+ provider: Provider
35
+ info: Info
36
+ role:
37
+ user:
38
+ roles: "Roles"
39
+ authentications: "Authentication methods"
40
+ emails: "List of emails"
41
+ created_at: "Created at"
42
+ updated_at: "Updated at"
43
+ authenticated_at: "Authenticated at"
44
+ user_email:
45
+ confirmed: Confirmed
46
+
47
+ user_registration_form:
48
+
49
+ errors:
50
+ messages:
51
+ user_not_found: "Failed to find user"
52
+ user_email_not_found: "Failed to find user email"
53
+ account_already_activated: "Account is already activated"
54
+ email_already_confirmed: "Email is already confirmed"
55
+ invalid_confirmation_token: "Confirmation token is invalid"
56
+
57
+ attributes:
58
+ email:
59
+ not_registered: "is not registered for any user"
60
+ already_confirmed: "is already confirmed"
61
+ password_login_not_allowed: "does not allow to log in using password"
62
+ roles:
63
+ invalid_roles: "contains invalid roles"
64
+
65
+
@@ -0,0 +1,64 @@
1
+ ru:
2
+ attributes:
3
+ created_at: "Создано"
4
+ updated_at: "Изменено"
5
+ email: "Email"
6
+ full_name: "Полное имя"
7
+ password: "Пароль"
8
+ password_confirmation: "Подтверждение пароля"
9
+ name: "Наименование"
10
+ uid: "UID"
11
+ id: "ID"
12
+ slug: "Код"
13
+
14
+ mongoid:
15
+ models:
16
+ access: Доступ
17
+ authentication: Метод аутентификации
18
+ role: Роль
19
+ user: Пользователь
20
+ user_email: Email пользователя
21
+ user_registration_form: Форма регистрации пользователя
22
+ user_request_account_activation_form: Форма запроса активации учётной записи
23
+ user_request_email_confirmation_form: Форма запроса подтверждения email адреса
24
+ user_request_password_reset_form: Форма запроса переустановки пароля
25
+ user_reset_password_form: Форма переустановки пароля
26
+
27
+ attributes:
28
+ access:
29
+ path: Путь
30
+ access: Доступ
31
+ role: Роль
32
+ authentication:
33
+ provider: Провайдер
34
+ info: Info
35
+ role:
36
+ user:
37
+ roles: "Роли"
38
+ authentications: "Методы аутентификации"
39
+ emails: "Список email адресов"
40
+ created_at: "Создан"
41
+ updated_at: "Обновлён"
42
+ authenticated_at: "Вход выполнен"
43
+ user_email:
44
+ confirmed: Подтверждён
45
+
46
+ user_registration_form:
47
+
48
+
49
+ errors:
50
+ messages:
51
+ user_not_found: "Не удалось найти пользователя"
52
+ user_email_not_found: "Не удалось найти email пользователя"
53
+ account_already_activated: "Учётная запись уже активирована"
54
+ email_already_confirmed: "Адрес email уже подтверждён"
55
+ invalid_confirmation_token: "Неправильный код подтверждения"
56
+
57
+ attributes:
58
+ email:
59
+ not_registered: "не зарегистрирован ни у одного пользователя"
60
+ already_confirmed: "уже подтвержден"
61
+ password_login_not_allowed: "не позволяет выполнять вход с помощью пароля"
62
+ roles:
63
+ invalid_roles: "содержит неправильные роли"
64
+
@@ -0,0 +1,122 @@
1
+ en:
2
+ aerogel:
3
+ users:
4
+ views:
5
+ login:
6
+ forgot_your_password: Forgot your password?
7
+ remember_me: Remember me
8
+ you_can_also_login_with: You can also log in with
9
+
10
+ logout:
11
+ text: |
12
+ <p>You have successfully logged out.<p>
13
+ <p>Proceed to <a href='/'>home page</a>.<p>
14
+
15
+ index:
16
+ title: "Account details"
17
+ edit:
18
+ title: "Edit account details"
19
+
20
+
21
+
22
+ register: ''
23
+ register_success:
24
+ title: "Almost there..."
25
+ text: |
26
+ <p>Your account is almost ready.</p>
27
+ <p>
28
+ We have sent you a message with a link to confirm your email address.
29
+ Open the message and click the link to activate the account.
30
+ </p>
31
+
32
+ request_account_activation:
33
+ title: "Request account activation"
34
+ text: |
35
+ <p>
36
+ You haven't received an account activation message from us? Try requesting this message again.
37
+ </p>
38
+
39
+ request_account_activation_success:
40
+ title: "Account activation message sent"
41
+ text: |
42
+ <p>
43
+ We have sent you a message with a link to confirm your email address.
44
+ Open the message and click the link to activate the account.
45
+ </p>
46
+
47
+ request_email_confirmation:
48
+ title: "Request email confirmation"
49
+ text: |
50
+ <p>
51
+ You haven't received an email confirmation message from us? Try requesting this message again.
52
+ </p>
53
+
54
+ request_email_confirmation_success:
55
+ title: "Email confirmation message sent"
56
+ text: |
57
+ <p>
58
+ We have sent you a message with a link to confirm your email address.
59
+ Open the message and click the link to confirm it.
60
+ </p>
61
+
62
+ request_password_reset:
63
+ title: "Request password reset"
64
+ text: |
65
+ <p>
66
+ Forgot your password? You can request reset of your password here.
67
+ An email will be sent to you with further instructions.
68
+ </p>
69
+
70
+ request_password_reset_success:
71
+ title: "Password reset message sent"
72
+ text: |
73
+ <p>
74
+ We have sent you a message with a link to password reset page.
75
+ Open the message and click the link to set new password.
76
+ </p>
77
+
78
+ activate_account:
79
+ title: "Success!"
80
+ text: |
81
+ <p>
82
+ Welcome, %{full_name}! Your account is activated.
83
+ </p>
84
+ <p>
85
+ You can <a href="/user/login">log in</a> to your account now.
86
+ </p>
87
+
88
+ activate_account_failure:
89
+ title: "Failed to activate account"
90
+ text: |
91
+ <p>
92
+ Account activation failed.
93
+ Be sure that you have copied the complete URL and try again.
94
+ </p>
95
+
96
+ confirm_email:
97
+ title: "Success!"
98
+ text: |
99
+ <p>
100
+ Your email address is confirmed.
101
+ </p>
102
+
103
+ confirm_email_failure:
104
+ title: "Failed to confirm email"
105
+ text: |
106
+ <p>
107
+ Email confirmation failed.
108
+ Be sure that you have copied the complete URL and try again.
109
+ </p>
110
+
111
+ reset_password:
112
+ title: "Reset password"
113
+
114
+ reset_password_success:
115
+ title: Password successfully changed
116
+ text: |
117
+ <p>
118
+ Your new password is set. You can now <a href='/user/login'>log in</a> to your account.
119
+ </p>
120
+
121
+
122
+