phoenix_auth 0.2.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README.md +2 -0
  2. data/app/assets/stylesheets/user.css +0 -0
  3. data/app/controllers/phoenix/base_controller_decorator.rb +8 -0
  4. data/app/controllers/phoenix/confirmations_controller.rb +16 -0
  5. data/app/controllers/phoenix/passwords_controller.rb +16 -0
  6. data/app/controllers/phoenix/profiles_controller.rb +17 -0
  7. data/app/controllers/phoenix/registrations_controller.rb +52 -0
  8. data/app/controllers/phoenix/sessions_controller.rb +35 -0
  9. data/app/controllers/phoenix/users_controller.rb +32 -0
  10. data/app/helpers/phoenix/users_helper.rb +4 -0
  11. data/app/mailers/phoenix/user_mailer.rb +30 -0
  12. data/app/models/phoenix/profile.rb +10 -0
  13. data/app/models/phoenix/user.rb +69 -0
  14. data/app/models/phoenix/user_observer.rb +7 -0
  15. data/app/views/phoenix/confirmations/new.html.haml +16 -0
  16. data/app/views/phoenix/layouts/login.html.erb +24 -0
  17. data/app/views/phoenix/layouts/login.html.haml +19 -0
  18. data/app/views/phoenix/layouts/mailer.html.haml +7 -0
  19. data/app/views/phoenix/passwords/edit.html.haml +21 -0
  20. data/app/views/phoenix/passwords/new.html.haml +13 -0
  21. data/app/views/phoenix/profiles/index.html.haml +2 -0
  22. data/app/views/phoenix/registrations/edit.html.haml +5 -0
  23. data/app/views/phoenix/registrations/new.html.erb +12 -0
  24. data/app/views/phoenix/registrations/new.html.haml +14 -0
  25. data/app/views/phoenix/sessions/authorization_failure.html.haml +23 -0
  26. data/app/views/phoenix/sessions/new.html.erb +41 -0
  27. data/app/views/phoenix/sessions/new.html.haml +27 -0
  28. data/app/views/phoenix/user_mailer/confirmation_instructions.html.haml +8 -0
  29. data/app/views/phoenix/user_mailer/reset_password_instructions.html.haml +16 -0
  30. data/app/views/phoenix/user_mailer/welcome_instructions.html.haml +2 -0
  31. data/app/views/phoenix/users/edit.html.haml +1 -0
  32. data/app/views/phoenix/users/index.html.haml +12 -0
  33. data/app/views/phoenix/users/profile.html.erb +8 -0
  34. data/app/views/phoenix/users/profile.html.haml +7 -0
  35. data/app/views/phoenix/users/show.html.haml +12 -0
  36. data/config/initializers/custom_devise_failure.rb +8 -0
  37. data/config/initializers/devise.rb +136 -0
  38. data/config/locales/devise/en.yml +51 -0
  39. data/config/locales/devise/zh-CN.yml +120 -0
  40. data/config/locales/devise/zh-TW.yml +119 -0
  41. data/config/routes.rb +21 -0
  42. data/lib/phoenix/auth.rb +10 -0
  43. data/lib/phoenix/auth/engine.rb +33 -0
  44. data/lib/phoenix/token_resource.rb +17 -0
  45. data/lib/phoenix_auth.rb +1 -0
  46. data/lib/tasks/phoenix_auth_tasks.rake +4 -0
  47. metadata +113 -0
@@ -0,0 +1,14 @@
1
+ %h3 sign_up
2
+ = simple_form_for( resource, :as => resource_name, :url => registration_path(resource_name) ) do |f|
3
+ = devise_error_messages!
4
+ %p
5
+ = f.input :name
6
+ %p
7
+ = f.input :email
8
+ %p
9
+ = f.input :password
10
+ %p
11
+ = f.input :password_confirmation
12
+ %p
13
+ = f.button :submit
14
+ %br
@@ -0,0 +1,23 @@
1
+ %h2
2
+ Sign in
3
+
4
+ = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
5
+ %p
6
+ = f.label :email
7
+ %br
8
+ = f.email_field :email
9
+
10
+ %p
11
+ = f.label :password
12
+ %br
13
+ = f.password_field :password
14
+
15
+ - if devise_mapping.rememberable?
16
+ %p
17
+ = f.check_box :remember_me
18
+ = f.label :remember_me
19
+
20
+ %p
21
+ = f.submit "Sign in"
22
+
23
+ = render :partial => "devise/shared/links"
@@ -0,0 +1,41 @@
1
+ <div id="signin-form">
2
+ <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
3
+ <fieldset>
4
+ <legend>
5
+ Sign In
6
+ </legend>
7
+ <div class="clearfix">
8
+ <label><%= f.label :email %></label>
9
+ <div class="input">
10
+ <%= f.email_field :email %>
11
+ </div>
12
+ </div>
13
+ <div class="clearfix">
14
+ <label><%= f.label :password %></label>
15
+ <div class="input">
16
+ <%= f.password_field :password %>
17
+ </div>
18
+ </div>
19
+ <% if devise_mapping.rememberable? %>
20
+ <div class="clearfix">
21
+ <label></label>
22
+ <ul class="inputs-list">
23
+ <li>
24
+ <label> <%= f.check_box :remember_me %> <span><%= f.label :remember_me %></span> </label>
25
+ </li>
26
+ </ul>
27
+ </div>
28
+ <% end %>
29
+ <div class="clearfix">
30
+ <%= f.submit "Sign in" %>
31
+ </div>
32
+ <% end %>
33
+ <div class="clearfix">
34
+ <%= link_to t(:create_a_new_account), signup_path %>
35
+ <br />
36
+ <%= link_to "Forgot your password?", new_user_password_path %>
37
+ <br />
38
+ <%= link_to "Didn't receive confirmation instructions?", new_user_confirmation_path %>
39
+ </div>
40
+ </fieldset>
41
+ </div>
@@ -0,0 +1,27 @@
1
+ %h2
2
+ Sign in
3
+
4
+ = simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
5
+ %p
6
+ = f.label :email
7
+ %br
8
+ = f.email_field :email
9
+
10
+ %p
11
+ = f.label :password
12
+ %br
13
+ = f.password_field :password
14
+
15
+ - if devise_mapping.rememberable?
16
+ %p
17
+ = f.check_box :remember_me
18
+ = f.label :remember_me
19
+
20
+ %p
21
+ = f.submit "Sign in"
22
+
23
+ = link_to t(:create_a_new_account), signup_path
24
+ %br
25
+ = link_to "Forgot your password?", new_user_password_path
26
+ %br
27
+ = link_to "Didn't receive confirmation instructions?", new_user_confirmation_path
@@ -0,0 +1,8 @@
1
+ %p
2
+ Welcome using Phoenix Engine:
3
+ = @user.name
4
+ !
5
+
6
+ %p
7
+ You can confirm your account through the link below:
8
+ = link_to 'Confirm my account', confirmation_url(@user, :confirmation_token => @user.confirmation_token)
@@ -0,0 +1,16 @@
1
+ %p
2
+ Hello
3
+ = @user.name
4
+
5
+ %p
6
+ Someone has requested a link to change your password, and you can do this through the link below.
7
+
8
+ %p
9
+ /= @edit_password_reset_url
10
+ = link_to 'Change my password', edit_password_url(@user, :reset_password_token => @user.reset_password_token)
11
+
12
+ %p
13
+ If you didn't request this, please ignore this email.
14
+
15
+ %p
16
+ Your password won't change until you access the link above and create a new one.
@@ -0,0 +1,12 @@
1
+ %h2
2
+ All Users List
3
+ - @users.each do |user|
4
+ %p
5
+ User:
6
+ /= link_to user.name, user
7
+ / 如何打造新的用户id地址。。。。
8
+ = link_to user.name, user_path(user)
9
+ /= user_name_tag(user)
10
+ %br
11
+ = link_to "Change my password", edit_password_path(user)
12
+
@@ -0,0 +1,8 @@
1
+ <div id="user-profile">
2
+ <h3>User Profile</h3>
3
+ <% if current_user %>
4
+ <%= @user.name%>
5
+ <br />
6
+ <%= @user.email%>
7
+ <% end %>
8
+ </div>
@@ -0,0 +1,7 @@
1
+ %h2
2
+ User Info
3
+
4
+ - if current_user
5
+ = @user.name
6
+ %br
7
+ = @user.email
@@ -0,0 +1,12 @@
1
+ %h2
2
+ User Info
3
+
4
+ %h4
5
+ The activity of user xxx.
6
+
7
+ - if current_user
8
+ = @user.name
9
+ %br
10
+ = @user.email
11
+ %br
12
+ = link_to "Profile", user_profiles_url(current_user)
@@ -0,0 +1,8 @@
1
+ # Add this file to fix root_path issue with authenticate_user
2
+ # Detail: https://github.com/plataformatec/devise/issues/1229
3
+
4
+ module Devise
5
+ class FailureApp < ActionController::Metal
6
+ include Phoenix::Core::Engine.routes.url_helpers
7
+ end
8
+ end
@@ -0,0 +1,136 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in DeviseMailer.
6
+ config.mailer_sender = "zhuke.me@gmail.com"
7
+
8
+ # Configure the class responsible to send e-mails.
9
+ config.mailer = 'Phoenix::UserMailer'
10
+
11
+ # ==> ORM configuration
12
+ # Load and configure the ORM. Supports :active_record (default) and
13
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
14
+ # available as additional gems.
15
+ require 'devise/orm/mongoid'
16
+
17
+ # ==> Configuration for any authentication mechanism
18
+ # Configure which keys are used when authenticating an user. By default is
19
+ # just :email. You can configure it to use [:username, :subdomain], so for
20
+ # authenticating an user, both parameters are required. Remember that those
21
+ # parameters are used only when authenticating and not when retrieving from
22
+ # session. If you need permissions, you should implement that in a before filter.
23
+ config.authentication_keys = [ :email ]
24
+
25
+ # Tell if authentication through request.params is enabled. True by default.
26
+ # config.params_authenticatable = true
27
+
28
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
29
+ config.http_authenticatable = true
30
+
31
+ # Set this to true to use Basic Auth for AJAX requests. True by default.
32
+ #config.http_authenticatable_on_xhr = false
33
+
34
+ # The realm used in Http Basic Authentication
35
+ config.http_authentication_realm = 'Phoenix Application'
36
+
37
+ # ==> Configuration for :database_authenticatable
38
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
39
+ # using other encryptors, it sets how many times you want the password re-encrypted.
40
+ config.stretches = 20
41
+
42
+ # Setup a pepper to generate the encrypted password.
43
+ config.pepper = '0bfa9e2cb4a5efd0d976518a3d82e345060547913d2fd1dd2f32b0c8dbbbb5d3dc20b86d0fed31aca9513bccdf51643700ea277d9c64d9ce8ef886bf39293453'
44
+
45
+ # ==> Configuration for :confirmable
46
+ # The time you want to give your user to confirm his account. During this time
47
+ # he will be able to access your application without confirming. Default is nil.
48
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
49
+ # You can use this to let your user access some features of your application
50
+ # without confirming the account, but blocking it after a certain period
51
+ # (ie 2 days).
52
+ config.confirm_within = 7.days
53
+
54
+ # ==> Configuration for :rememberable
55
+ # The time the user will be remembered without asking for credentials again.
56
+ config.remember_for = 2.weeks
57
+
58
+ # If true, a valid remember token can be re-used between multiple browsers.
59
+ # config.remember_across_browsers = true
60
+
61
+ # If true, extends the user's remember period when remembered via cookie.
62
+ # config.extend_remember_period = false
63
+
64
+ # ==> Configuration for :validatable
65
+ # Range for password length
66
+ config.password_length = 6..20
67
+
68
+ # Regex to use to validate the email address
69
+ config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
70
+
71
+ # ==> Configuration for :timeoutable
72
+ # The time you want to timeout the user session without activity. After this
73
+ # time the user will be asked for credentials again.
74
+ # config.timeout_in = 10.minutes
75
+
76
+ # ==> Configuration for :lockable
77
+ # Defines which strategy will be used to lock an account.
78
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
79
+ # :none = No lock strategy. You should handle locking by yourself.
80
+ # config.lock_strategy = :failed_attempts
81
+
82
+ # Defines which strategy will be used to unlock an account.
83
+ # :email = Sends an unlock link to the user email
84
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
85
+ # :both = Enables both strategies
86
+ # :none = No unlock strategy. You should handle unlocking by yourself.
87
+ # config.unlock_strategy = :both
88
+
89
+ # Number of authentication tries before locking an account if lock_strategy
90
+ # is failed attempts.
91
+ # config.maximum_attempts = 20
92
+
93
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
94
+ # config.unlock_in = 1.hour
95
+
96
+ # ==> Configuration for :token_authenticatable
97
+ # Defines name of the authentication token params key
98
+ config.token_authentication_key = :auth_token
99
+
100
+ # ==> Scopes configuration
101
+ # Turn scoped views on. Before rendering 'sessions/new', it will first check for
102
+ # 'users/sessions/new'. It's turned off by default because it's slower if you
103
+ # are using only default views.
104
+ # config.scoped_views = true
105
+
106
+ # Configure the default scope given to Warden. By default it's the first
107
+ # devise role declared in your routes.
108
+ # config.default_scope = :user
109
+
110
+ # Configure sign_out behavior.
111
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
112
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
113
+ # config.sign_out_all_scopes = false
114
+
115
+ # ==> Navigation configuration
116
+ # Lists the formats that should be treated as navigational. Formats like
117
+ # :html, should redirect to the sign in page when the user does not have
118
+ # access, but formats like :xml or :json, should return 401.
119
+ # If you have any extra navigational formats, like :iphone or :mobile, you
120
+ # should add them to the navigational formats lists. Default is [:html]
121
+ config.navigational_formats = [:html, :json, :xml]
122
+
123
+ # ==> Warden configuration
124
+ # If you want to use other strategies, that are not (yet) supported by Devise,
125
+ # you can configure them inside the config.warden block. The example below
126
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
127
+ #
128
+ # config.warden do |manager|
129
+ # manager.oauth(:twitter) do |twitter|
130
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
131
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
132
+ # twitter.options :site => 'http://twitter.com'
133
+ # end
134
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
135
+ # end
136
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2011, Phoenix Project.
2
+ # Devise i18n English.
3
+
4
+ en:
5
+ errors:
6
+ messages:
7
+ not_found: 'not found'
8
+ already_confirmed: 'was already confirmed'
9
+ not_locked: 'was not locked'
10
+ not_saved:
11
+ one: '1 error prohibited this %{resource} from being saved:'
12
+ other: '%{count} errors prohibited this %{resource} from being saved:'
13
+ devise:
14
+ failure:
15
+ unauthenticated: 'You need to sign in or sign up before continuing.'
16
+ unconfirmed: 'You have to confirm your account before continuing.'
17
+ locked: 'Your account is locked.'
18
+ invalid: 'Invalid email or password.'
19
+ invalid_token: 'Invalid authentication token.'
20
+ timeout: 'Your session expired, please sign in again to continue.'
21
+ inactive: 'Your account was not activated yet.'
22
+ user_passwords:
23
+ user:
24
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
25
+ updated: 'Your password was changed successfully. You are now signed in.'
26
+ confirmations:
27
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
28
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
29
+ user_registrations:
30
+ signed_up: 'Welcome! You have signed up successfully.'
31
+ inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
32
+ updated: 'You updated your account successfully.'
33
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
34
+ user_sessions:
35
+ signed_in: 'Signed in successfully.'
36
+ signed_out: 'Signed out successfully.'
37
+ unlocks:
38
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
39
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
40
+ oauth_callbacks:
41
+ success: 'Successfully authorized from %{kind} account.'
42
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
43
+ mailer:
44
+ confirmation_instructions:
45
+ subject: 'Please verify your email address'
46
+ welcome_instructions:
47
+ subject: 'Welcome using Phoenix Engine'
48
+ reset_password_instructions:
49
+ subject: 'Reset password instructions'
50
+ unlock_instructions:
51
+ subject: 'Unlock Instructions'
@@ -0,0 +1,120 @@
1
+ # Copyright (c) 2011, Phoenix Project.
2
+ # Devise i18n Chinese Simplified.
3
+
4
+
5
+ zh-CN:
6
+ devise:
7
+ confirmations:
8
+ confirmed: 帐号确认成功。您已经成功登录。
9
+ new:
10
+ resend_confirmation: "重送发送帐号确认邮件"
11
+ send_instructions: 您会在几分钟内收到一封邮件,它将指引您完成帐号确认步骤。
12
+ failure:
13
+ inactive: 你的帐号尚未激活。
14
+ invalid: 邮箱或密码有误。
15
+ invalid_token: 验证信息不合法。
16
+ locked: 您的帐号已锁定。
17
+ timeout: 会话超时。若要继续,请重新登录。
18
+ unauthenticated: 请您登录或注册。
19
+ unconfirmed: 你必须先验证帐号才能继续。
20
+ invitations:
21
+ invitation_token_invalid: 邀请码验证失败。
22
+ send_instructions: 邀请发送成功。
23
+ updated: 密码设定成功。您已经成功登录。
24
+ mailer:
25
+ confirmation_instructions:
26
+ confirm: "确认帐号"
27
+ subject: "帐号确认步骤"
28
+ you_can_confirm: 你可以点击下面的链接确认帐号:
29
+ hello: "您好, %{email}!"
30
+ invitation_instructions:
31
+ accept: "接收请求"
32
+ arrived: "The social network you have been waiting for has arrived. Revamped, more secure, and more fun, %{strong_diaspora} is ready to help you share and explore the web in a whole new way."
33
+ be_yourself: "Be Yourself"
34
+ be_yourself_paragraph: "The Internet has created unique new ways for us to express ourselves. %{strong_diaspora} lets you be yourself and share however you want, with or without your real name."
35
+ cubbies: Cubbi.es
36
+ displaying_correctly: "Email not displaying correctly? %{link} in your browser"
37
+ email_address: questions@joindiaspora.com
38
+ email_us: "For general inquiries or support with your Diaspora account, please email us at %{email}."
39
+ finally: "Finally - it's here"
40
+ friends_saying: "What your friends are saying..."
41
+ get_connected: "Get Connected"
42
+ get_connected_paragraph: "An international movement with a shared vision for a better web, %{strong_diaspora}'s #1 feature is its community. Meet new people, connect with friends, and join the fun."
43
+ have_fun: "Have Fun"
44
+ have_fun_paragraph: "%{strong_diaspora} is all about discovering amazing new content and people online. %{link}, the world's first %{strong_diaspora} application is just the begining. Collect and share the web in all of its glory."
45
+ help_fund: "help fund Diaspora"
46
+ here: "here"
47
+ ignore: 如果您不想接收这个邀请,请忽略这封邮件。
48
+ join_team: "Join our Team"
49
+ love: "Love,"
50
+ made_by_people: "%{strong_diaspora} is made by people who love the Internet as much as you do. %{jointeam}, or %{helpfund}!"
51
+ more_people: "Even more people are excited to see you!"
52
+ no_account_till: 只有在您点击上面的链接并注册后,您的帐号才会被创建。
53
+ or: "or"
54
+ sign_up_now: "Sign up now &rarr;"
55
+ subject: 您被邀请加入Diaspora!
56
+ team_diaspora: "Team Diaspora"
57
+ unsubscribe: "To unsubscribe please click %{link}."
58
+ view_in: "View in"
59
+ inviter:
60
+ accept_at: "at %{url}, you can accept it through the link below."
61
+ has_invited_you: "%{name}"
62
+ have_invited_you: "%{names} have invited you to join Diaspora"
63
+ reset_password_instructions:
64
+ change: "重置密码"
65
+ ignore: "如果您并没有请求重置密码, 请忽略这封信件。"
66
+ someone_requested: 有人请求重置您的密码,若确实要这么做,请点击下面的链接。
67
+ subject: "密码重置步骤"
68
+ wont_change: 在点击以上链接重置密码后,您的密码才会改变。
69
+ unlock_instructions:
70
+ account_locked: 您的帐号因为登录失败次数异常而被锁定。
71
+ click_to_unlock: 点击下面的链接以解锁您的帐号:
72
+ subject: "帐号解锁步骤"
73
+ unlock: "解锁帐号"
74
+ welcome: "欢迎您, %{email}!"
75
+ passwords:
76
+ edit:
77
+ change_password: "修改密码"
78
+ new:
79
+ forgot_password: 忘记密码?
80
+ no_account: "没有与此邮箱关联的帐号。如果您在等待邀请函, 我们将尽快寄出."
81
+ send_password_instructions: "请向我发送密码重置步骤"
82
+ send_instructions: 几分钟内您将收到一封包含密码重置步骤的邮件。
83
+ updated: 密码修改成功。您已经登入了。
84
+ registrations:
85
+ destroyed: 再见!您的帐号已经关闭。希望不久后再会。
86
+ signed_up: "您已经成功注册。如果有设定的话, 确认信会送到您的邮箱。"
87
+ updated: 帐号更新成功。
88
+ sessions:
89
+ new:
90
+ alpha_software: 你即将使用处于开发初期的功能。
91
+ bugs_and_feedback: "给您一个提醒, 你将可能遇到bug。 遇到任何问题,都请您点击浏览器右边的\"反馈\"按钮向我们反馈! 我们会尽快处理您反馈的任何问题。"
92
+ bugs_and_feedback_mobile: "给您一个提醒, 你将可能遇到bug。 遇到任何问题都请你向我们反馈! 我们会尽快处理你反馈的任何问题."
93
+ login: "登录"
94
+ modern_browsers: 只支持较新的浏览器。
95
+ password: "密码"
96
+ remember_me: "记住密码"
97
+ sign_in: "登录"
98
+ username: "用户名"
99
+ signed_in: 登录成功。
100
+ signed_out: 登出成功。
101
+ shared:
102
+ links:
103
+ forgot_your_password: 忘记密码?
104
+ receive_confirmation: 没有收到确认步骤?
105
+ receive_unlock: 没有收到重置步骤?
106
+ sign_in: "登录"
107
+ sign_up: "注册"
108
+ sign_up_closed: 目前不开放公开注册。
109
+ mail_signup_form:
110
+ sign_up_for_an_invite: 凭邀请函注册!
111
+ unlocks:
112
+ new:
113
+ resend_unlock: "重新发送解锁步骤"
114
+ send_instructions: 几分钟后您将收到一封邮件,它将指引您解锁您的帐号。
115
+ unlocked: 帐号解锁成功。你已经登录。
116
+ errors:
117
+ messages:
118
+ already_confirmed: "已确认"
119
+ not_found: "未找到"
120
+ not_locked: "未锁定"