rad_users 0.0.1 → 0.0.2

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 (66) hide show
  1. data/Rakefile +1 -0
  2. data/app/controllers/identities.rb +160 -0
  3. data/app/controllers/profiles.rb +61 -0
  4. data/app/controllers/sessions.rb +78 -0
  5. data/app/controllers/user_mailer.rb +30 -0
  6. data/app/controllers/user_management.rb +9 -0
  7. data/app/controllers/users_app.rb +9 -0
  8. data/app/helpers/users/authorization.rb +65 -0
  9. data/app/helpers/users/general.rb +22 -0
  10. data/app/models/avatar_file.rb +33 -0
  11. data/app/models/user.rb +105 -0
  12. data/app/models/user/email_verification_token.rb +20 -0
  13. data/app/models/user/forgot_password_token.rb +12 -0
  14. data/app/static/open_id.js +2 -0
  15. data/app/static/openid-selector/css/openid.css +45 -0
  16. data/app/static/openid-selector/demo.html +58 -0
  17. data/app/static/openid-selector/demoOpenIDClient.html +69 -0
  18. data/app/static/openid-selector/images/aol.gif +0 -0
  19. data/app/static/openid-selector/images/blogger.ico +0 -0
  20. data/app/static/openid-selector/images/claimid.ico +0 -0
  21. data/app/static/openid-selector/images/facebook.gif +0 -0
  22. data/app/static/openid-selector/images/flickr.ico +0 -0
  23. data/app/static/openid-selector/images/google.gif +0 -0
  24. data/app/static/openid-selector/images/livejournal.ico +0 -0
  25. data/app/static/openid-selector/images/myopenid.ico +0 -0
  26. data/app/static/openid-selector/images/openid-inputicon.gif +0 -0
  27. data/app/static/openid-selector/images/openid.gif +0 -0
  28. data/app/static/openid-selector/images/technorati.ico +0 -0
  29. data/app/static/openid-selector/images/verisign.gif +0 -0
  30. data/app/static/openid-selector/images/verisign.ico +0 -0
  31. data/app/static/openid-selector/images/vidoop.ico +0 -0
  32. data/app/static/openid-selector/images/wordpress.ico +0 -0
  33. data/app/static/openid-selector/images/yahoo.gif +0 -0
  34. data/app/static/openid-selector/js/jquery-1.2.6.min.js +32 -0
  35. data/app/static/openid-selector/js/openid-client/jquery.query-2.1.3.js +220 -0
  36. data/app/static/openid-selector/js/openid-client/openid-client-config.js +20 -0
  37. data/app/static/openid-selector/js/openid-client/openid-client.js +63 -0
  38. data/app/static/openid-selector/js/openid-jquery.js +240 -0
  39. data/app/static/openid-selector/openid-client/checkid_immediate_response.html +3 -0
  40. data/app/static/openid-selector/openid-client/checkid_setup_response.html +3 -0
  41. data/app/static/themes/default/users.css +947 -0
  42. data/app/static/themes/default/users.less +4 -0
  43. data/app/views/controllers/identities/enter_email_form.html.haml +6 -0
  44. data/app/views/controllers/identities/finish_email_registration_form.html.haml +23 -0
  45. data/app/views/controllers/identities/finish_open_id_registration_form.html.haml +12 -0
  46. data/app/views/controllers/identities/forgot_password_form.html.haml +6 -0
  47. data/app/views/controllers/identities/reset_password_form.html.haml +9 -0
  48. data/app/views/controllers/identities/update_password_form.html.haml +11 -0
  49. data/app/views/controllers/profiles/_form.html.haml +15 -0
  50. data/app/views/controllers/profiles/_roles.html.haml +6 -0
  51. data/app/views/controllers/profiles/_user.html.haml +24 -0
  52. data/app/views/controllers/profiles/actions.js.haml +12 -0
  53. data/app/views/controllers/profiles/all.html.haml +3 -0
  54. data/app/views/controllers/profiles/show.html.haml +1 -0
  55. data/app/views/controllers/sessions/_open_id_form.html.haml +16 -0
  56. data/app/views/controllers/sessions/_password_form.html.haml +13 -0
  57. data/app/views/controllers/sessions/login.html.haml +8 -0
  58. data/app/views/controllers/sessions/status.html.haml +1 -0
  59. data/app/views/themes/default/user.html.haml +8 -0
  60. data/app/views/users/_menu.html.haml +6 -0
  61. data/app/views/users/layout.html.haml +10 -0
  62. data/app/views/users/layout.js.haml +1 -0
  63. data/config/locales/en.yml +103 -0
  64. data/config/locales/ru.yml +105 -0
  65. data/config/routes.rb +18 -0
  66. metadata +71 -7
@@ -0,0 +1,4 @@
1
+ @import "../../../../../common_interface/app/static/themes/default/style";
2
+
3
+ .the_user {.s_box; .s_round;
4
+ .l_properties {}}
@@ -0,0 +1,6 @@
1
+ = b.title t(:new_user_title)
2
+ - b.narrow do
3
+ - b.form_for :token, @token, action: url_for(:enter_email) do |f|
4
+ = f.text_field :email, required: true, description: t(:signup_email_description)
5
+ = f.line
6
+ = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,23 @@
1
+ = b.title t(:new_user_title)
2
+ - b.narrow do
3
+ - b.form_for :user, @user, action: finish_email_registration_identities_path do |f|
4
+ = f.hidden_field_tag :token, @token.token
5
+
6
+ = f.text_field :name, required: true, description: t(:choose_name_description)
7
+ = f.password_field :password, required: true
8
+ = f.password_field :password_confirmation, required: true
9
+
10
+ = f.line
11
+ = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
12
+
13
+ / - b.form_for @user, url: {action: (@user.new_record? ? 'create' : 'update')} do |f|
14
+ / = f.error_messages
15
+ /
16
+ / = f.text_field :name, required: true, label: t(:username)
17
+ / = f.text_field :email, required: true
18
+ / = f.password_field :password, required: true
19
+ / = f.password_field :password_confirmation, required: true
20
+ /
21
+ / = f.line
22
+ /
23
+ / = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,12 @@
1
+ = b.title t(:choose_name)
2
+ - b.narrow do
3
+ / - p persist_params?
4
+ / - p params
5
+ - b.form_for :user, @user, action: finish_open_id_registration_identities_path do |f|
6
+ = f.error_messages
7
+
8
+ = f.hidden_field_tag :token, @token.token
9
+
10
+ = f.text_field :name, required: true, description: t(:choose_name_description)
11
+
12
+ = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,6 @@
1
+ = b.title t(:forgot_password)
2
+ - b.narrow do
3
+ - b.form_tag action: forgot_password_identities_path do |f|
4
+ = f.text_field_tag :email, @email, required: true, label: t(:email), description: t(:forgot_password_hint)
5
+
6
+ = f.line f.submit_tag(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,9 @@
1
+ = b.title t(:reset_password)
2
+ - b.narrow do
3
+ - b.form_for :user, @user, action: reset_password_identities_path do |f|
4
+ = f.hidden_field_tag :token, @token.token
5
+
6
+ = f.password_field :password, required: true, label: t(:new_password)
7
+ = f.password_field :password_confirmation, required: true #, label: t(:password_confirmation)
8
+
9
+ = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,11 @@
1
+ = b.title t(:edit_password_title)
2
+ - b.narrow do
3
+ - b.form_for :user, @user, action: update_password_identities_path do |f|
4
+ = f.error_messages
5
+
6
+ = f.password_field_tag :old_password, '', label: t(:old_password), required: true
7
+
8
+ = f.password_field :password, required: true, label: t(:password)
9
+ = f.password_field :password_confirmation, required: true, label: t(:password_confirmation)
10
+
11
+ = f.line f.submit(t(:ok)), link_to(t(:cancel), :back)
@@ -0,0 +1,15 @@
1
+ - b.form_for :user, @user, action: form_action, enctype: "multipart/form-data" do |f|
2
+ = f.error_messages
3
+
4
+ = f.text_field :first_name
5
+ = f.text_field :last_name
6
+
7
+ - if @user.avatar.blank?
8
+ = f.file_field :avatar
9
+ - else
10
+ - img = image_tag(Models::User.avatar_url(@user.name), style: 'max-width: 150px; max-height: 150px;')
11
+ = f.file_field :avatar, label: "#{t(:avatar)}#{"<br/>" + img}"
12
+
13
+ = f.line
14
+
15
+ = f.line ok_button, cancel_button
@@ -0,0 +1,6 @@
1
+ - unless @user.anonymous?
2
+ #user_roles
3
+ / = b.subtitle t(:roles)
4
+ - b.basic_list do
5
+ - roles_control_links_for(@user).each do |text|
6
+ = b.basic_list_item text
@@ -0,0 +1,24 @@
1
+ - b.user id: @user.dom_id do |o|
2
+ - o.title @user.name
3
+
4
+ - o.controls do |a|
5
+ - a.add link_to(t(:edit), edit_profile_path(@user, format: :js)) if can?(:update_profile, @user) or (@user.anonymous? and user.roles.admin?)
6
+
7
+ - o.avatar image_tag(Models::User.avatar_url(@user.name))
8
+
9
+ - o.properties do
10
+ - b.basic_list do
11
+ = b.basic_list_item h("#{@user.first_name} #{@user.last_name}")
12
+
13
+ - b.text do
14
+ .todo= link_to(t(:update_password), update_password_form_identities_path) if owner? @user
15
+
16
+ .todo about
17
+
18
+ = render 'roles'
19
+
20
+ - o.content do
21
+ .todo
22
+ - b.basic_list do
23
+ = b.basic_list_item 'Latest Activity ...'
24
+ = b.basic_list_item 'Public Items ...'
@@ -0,0 +1,12 @@
1
+ - case action_name
2
+
3
+ - when :edit
4
+ - form = js render('form', locals: {form_action: update_profile_path(@user, format: :js)});
5
+ rad.dialog().show('#{form}');
6
+
7
+ - when :update
8
+ - html = js render('user');
9
+ $('{@user.dom_id}').replaceWith("#{html}");
10
+
11
+ - else
12
+ - must_be.never_called
@@ -0,0 +1,3 @@
1
+ - b.text do
2
+ - @users.each do |user|
3
+ = link_to user.name, user_path(user)
@@ -0,0 +1 @@
1
+ = render 'user'
@@ -0,0 +1,16 @@
1
+ - content_for :head do
2
+ = stylesheet_link_tag *merged_stylesheets(:open_id)
3
+
4
+ - content_for :bottom do
5
+ = javascript_include_tag *merged_javascripts(:open_id)
6
+ - javascript_tag do
7
+ $(function() {openid.init('openid_identifier')});
8
+ / openid.setDemoMode(true);
9
+
10
+ - form_tag(action: login_path, id: "openid_form") do
11
+ #openid_choice
12
+ #openid_btns
13
+
14
+ #openid_input_area
15
+ %input{id: "openid_identifier", name: "openid_identifier", type: "text", value: "http://"}
16
+ %input{id: "openid_submit", type: "submit", value: "Sign-In"}
@@ -0,0 +1,13 @@
1
+ - b.form_tag action: login_path do |f|
2
+ = f.error_messages @errors
3
+
4
+ = f.text_field_tag :name, @name, required: true, label: t(:username)
5
+ = f.password_field_tag :password, "", required: true, label: t(:password)
6
+
7
+ = f.line
8
+
9
+ = f.line ok_button, cancel_button
10
+
11
+ = f.line
12
+
13
+ = f.line link_to(t(:register_link), signup_path), link_to(t(:forgot_password_link), forgot_password_form_identities_path)
@@ -0,0 +1,8 @@
1
+ = b.title t(:login_title)
2
+ - b.narrow do
3
+ = render 'password_form'
4
+
5
+ / - b.more name: t(:login_using_open_id), id: :open_id do
6
+ / = b.title t(:login_using_open_id)
7
+ / - b.narrow do
8
+ / = render 'open_id_form'
@@ -0,0 +1 @@
1
+ = "Hello, #{Models::User.current.name}."
@@ -0,0 +1,8 @@
1
+ - tag :div, object.merge_html_attributes(class: " the_user") do
2
+ - if object.controls?
3
+ .l_controls= object.controls.join(' ')
4
+
5
+ .l_name= object.name
6
+ .l_avatar= object.avatar
7
+ .l_properties= object.properties
8
+ .l_content= object.content
@@ -0,0 +1,6 @@
1
+ / TODO3 remove or refactor it
2
+ - unless (menu = main_menu).blank?
3
+ - b.navigation do |o|
4
+ - o.items do |a|
5
+ - menu.each do |name, link, active|
6
+ = a.add content: link_to(name, link), active: active
@@ -0,0 +1,10 @@
1
+ - content_for :nothing do
2
+ - content_for :css do
3
+ = stylesheet_link_tag '/themes/default/users.css'
4
+
5
+ - content_for :top_panel, render('/kit/top_panel')
6
+ - content_for :navigation, render('/users/menu')
7
+ - content_for :bottom_panel, render('/kit/bottom_panel')
8
+
9
+ - @build_layout = false
10
+ = render '/kit/layout'
@@ -0,0 +1 @@
1
+ = render '/kit/layout'
@@ -0,0 +1,103 @@
1
+ en:
2
+ # General
3
+ anonymous: "Welcome, Guest"
4
+ are_you_shure: "Are you sure?"
5
+ avatar: "Avatar"
6
+ domains: "Domains"
7
+ email: "eMail"
8
+ home: "Home"
9
+ login: "Login"
10
+ login_not_required: "You are already logged in"
11
+ login_required: "You need to be logged in"
12
+ logout: "Logout"
13
+ name: "Name"
14
+ password: "Password"
15
+ show_more: "..."
16
+ signup: "Signup"
17
+ state: "State"
18
+ username: "Username"
19
+ users: "Users"
20
+
21
+ # User model
22
+ bad_email_message: "Invalid email"
23
+ bad_login_message: "Invalid login (use only 0-9, a-z, and .-_@ symbols)"
24
+ first_name: "First Name"
25
+ last_name: "Last Name"
26
+ password_confirmation: "Password confirmation"
27
+
28
+ # Space model
29
+ forbiden_to_change_default_space: "Forbidden to change default Space"
30
+
31
+ # Wigets
32
+ callback_error: "Service Mix callback error!"
33
+ callback_error_not_specified: "Callback error not defined!"
34
+
35
+ # Authorization
36
+ admin: "Admin"
37
+ add_admin_role: "Add to Admins"
38
+ add_custom_role: "Grant '%{role}' role"
39
+ add_manager_role: "Add to Managers"
40
+ add_member_role: "Add to Members"
41
+ custom_role: "%{role}"
42
+ manager: "Manager"
43
+ member: "Member"
44
+ remove_admin_role: "Remove from Admins"
45
+ remove_custom_role: "Remove '%{role}' role"
46
+ remove_manager_role: "Remove from Managers"
47
+ remove_member_role: "Remove from Members"
48
+ role_granted: "Role granted"
49
+ role_removed: "Role removed"
50
+ invalid_roles: "Invalid roles"
51
+
52
+ # Authentication
53
+ choose_name: "Choose username"
54
+ choose_name_description: "Choose username (can't be changed in future)"
55
+ edit_password_title: "Update password"
56
+ email_verification_code_sent: "To complete registration please follow the link sent to Your email %{email}."
57
+ failed_reset_password: "No user with such email %{email}!"
58
+ forgot_password_hint: "Link for password restore will be send to Your email"
59
+ forgot_password_link: "Forgot password?"
60
+ forgot_password: "Restore password"
61
+ invalid_email_verification_token: "Email confirmation code is invalid or expired"
62
+ invalid_identity: "No user with such ID (%{identity_url})"
63
+ invalid_login: "Invalid login or password"
64
+ invalid_old_password: "Invalid old password"
65
+ invalid_reset_password_token: "The code for password restoration is invalid or expired"
66
+ login_title: "Login"
67
+ login_using_open_id: "Login using OpenID"
68
+ new_password: "New password"
69
+ new_user_title: "Signup"
70
+ not_unique_email: "User with such email already exists"
71
+ old_password: "Old password"
72
+ open_id: "OpenID"
73
+ openid_identifier: "OpenID"
74
+ password_restored: "Password updated"
75
+ password_updated: "Pasword updated"
76
+ register_link: "Signup"
77
+ reset_password: "Reset password"
78
+ should_not_be_blank: "should not be blank"
79
+ signup_email_description: "To finish registration please follow the link that will be send to Your email"
80
+ successfully_identified_by_open_id: "Identification is successfully finished"
81
+ successfully_logged_in: "You are logged in"
82
+ successfully_logged_out: "You are logged out"
83
+ successfull_open_id_registration: "You are successfully registered and can log in"
84
+ successfully_registered: "You are successfully registered and can login"
85
+ sucessfully_reset_password: "Link for password restoration sent to Your email: %{email}"
86
+ update_password: "Update password"
87
+
88
+
89
+
90
+ #
91
+ # EMail
92
+ #
93
+ email_verification_title: "Registration on site %{host}"
94
+ email_verification_text: |
95
+ To finish registration on site %{host} please follow this link:
96
+ %{url}
97
+
98
+ forgot_password_title: "Password reset for %{name} on the %{host} site"
99
+ forgot_password_text: |
100
+ You (or somebody else by entering Your email) requested password reset for Your account %{name} on the %{host} site.
101
+
102
+ To reset password please follow this link %{url}
103
+ (or just delete this email and Your password will remain intact)
@@ -0,0 +1,105 @@
1
+ ru:
2
+ anonymous: "Добро пожаловать, Гость"
3
+ are_you_shure: "Уверены?"
4
+ avatar: "Аватар"
5
+ domains: "Домены"
6
+ email: "Почта"
7
+ home: "Главная"
8
+ login: "Войти"
9
+ login_not_required: "Вы уже вошли"
10
+ login_required: "Для получения доступа необходимо войти в систему"
11
+ logout: "Выйти"
12
+ name: "Имя"
13
+ password: "Пароль"
14
+ show_more: "..."
15
+ signup: "Регистрация"
16
+ state: "Статус"
17
+ username: "Логин"
18
+ users: "Пользователи"
19
+
20
+ # User model
21
+ bad_email_message: "Должен быть правильным почтовым адресом"
22
+ bad_login_message: "Используйте буквы, цифры и .-_@"
23
+ first_name: "Имя"
24
+ last_name: "Фамилия"
25
+ password_confirmation: "Подтверждение пароля"
26
+
27
+ # Space model
28
+ forbiden_to_change_default_space: "Нельзя менять дефолтную область"
29
+
30
+ # Wigets
31
+ callback_error: "Ошибка калбека Service Mix!"
32
+ callback_error_not_specified: "Ошибка калбека не определена!"
33
+
34
+ # Authorization
35
+ admin: "Админ"
36
+ add_admin_role: "Сделать Админом"
37
+ add_custom_role: "Сделать '%{role}'"
38
+ add_manager_role: "Сделать Менеджером"
39
+ add_member_role: "Принять в сообщество"
40
+ custom_role: "%{role}"
41
+ manager: "Менеджер"
42
+ member: "Участник"
43
+ remove_admin_role: "Убрать права Админа"
44
+ remove_custom_role: "Убрать права '%{role}'"
45
+ remove_manager_role: "Убрать права Менеджера"
46
+ remove_member_role: "Удалить из сообщества"
47
+ role_granted: "Права даны"
48
+ role_removed: "Права убраны"
49
+ invalid_roles: "Неверные роли"
50
+
51
+ # Authentication
52
+ choose_name: "Выберите имя пользователя"
53
+ choose_name_description: "Выберите имя пользователя (в дальнейшем изменить нельзя)"
54
+ edit_password_title: "Изменение пароля"
55
+ email_verification_code_sent: "Чтобы завершить регистрацию перейдите пожалуйста по ссылке высланной вам на почту %{email}"
56
+ failed_reset_password: "Пользвателя с почтой %{email} не существует!"
57
+ forgot_password_hint: "Ссылка для восстановления пароля будет выслана вам на почту"
58
+ forgot_password_link: "Забыли пароль?"
59
+ forgot_password: "Восстановление пароля"
60
+ invalid_email_verification_token: "Неверный код подтверждения почты, возможно у него истек срок действия"
61
+ invalid_identity: "Пользователя с таким ID не существует (%{identity_url})"
62
+ invalid_login: "Неверный логин или пароль"
63
+ invalid_old_password: "Неверный старый пароль"
64
+ invalid_reset_password_token: "Неверный код восстановления пароля, возможно у него истек срок действия"
65
+ login_title: "Войти"
66
+ login_using_open_id: "Войти используя OpenID"
67
+ new_password: "Новый пароль"
68
+ new_user_title: "Регистрация"
69
+ not_unique_email: "Пользователь с таким адресом уже существует"
70
+ old_password: "Старый пароль"
71
+ open_id: "OpenID"
72
+ openid_identifier: "OpenID"
73
+ password_restored: "Пароль изменен"
74
+ password_updated: "Пароль изменен"
75
+ register_link: "Регистрация"
76
+ reset_password: "Сброс пароля"
77
+ should_not_be_blank: "не заполнен"
78
+ signup_email_description: "Вам на почту будет выслана ссылка для завершения решистрации"
79
+ successfully_identified_by_open_id: "Идентификация успешно завершена"
80
+ successfully_logged_in: "Вы вошли"
81
+ successfully_logged_out: "Вы вышли"
82
+ successfull_open_id_registration: "Вы успешно зарегистрированы и можете войти"
83
+ successfully_registered: "Вы успешно зарегистрировались и можете войти в систему"
84
+ sucessfully_reset_password: "Ссылка для восстановления пароля выслана вам на почту: %{email}"
85
+ update_password: "Изменить пароль"
86
+
87
+
88
+ #
89
+ # EMail
90
+ #
91
+ email_verification_title: "Регистрация аккаунта на %{host}"
92
+ email_verification_text: |
93
+ Чтобы завершить решистрацию на %{host} перейдите пожалуйста по ссылке:
94
+ %{url}
95
+
96
+ # email_activation_title: "%{name}, ваш аккаунт на %{host} активирован"
97
+ # email_activation_text: |
98
+ # %{name} ваш аккаунт на %{host} активирован.
99
+
100
+ forgot_password_title: "Сброс пароля пользователя %{name} на %{host}"
101
+ forgot_password_text: |
102
+ Вы (или кто-то другой введя вашу почту) запросили сброс пароля для вашего аккаунта %{name} на %{host}
103
+
104
+ Чтобы сбросить пароль перейдите по ссылке %{url}
105
+ (или просто удалите это письмо, ваш пароль останется как и раньше)
@@ -0,0 +1,18 @@
1
+ url_root = rad.users.url_root
2
+
3
+ rad.router.configure do |c|
4
+ c.persistent_params :l
5
+
6
+ c.with_options url_root: url_root do |c|
7
+ c.alias '/login', class_name: 'Controllers::Sessions', method: :login
8
+ c.alias '/logout', class_name: 'Controllers::Sessions', method: :logout
9
+ c.alias '/signup', class_name: 'Controllers::Identities', method: :enter_email_form
10
+
11
+ # c.resource :checks, class_name: 'Users::Checks'
12
+
13
+ c.resource :identities, class_name: 'Controllers::Identities'
14
+ c.resource :sessions, class_name: 'Controllers::Sessions'
15
+
16
+ c.resource :profiles, class_name: 'Controllers::Profiles'
17
+ end
18
+ end