-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/13 user sign up #67
Changes from 9 commits
8c41e57
2304a57
01b1c75
d61652a
5c45736
ac16e4d
020729a
438f4da
7ef5c71
c944846
b358713
64c8656
5776627
d61db31
69d428f
6f5f373
55a4176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
module ApplicationHelper | ||
def resource_name | ||
:user | ||
end | ||
|
||
def resource | ||
@resource ||= User.new | ||
end | ||
|
||
def devise_mapping | ||
@devise_mapping ||= Devise.mappings[:user] | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class User < ActiveRecord::Base | ||
# Include default devise modules. Others available are: | ||
# :token_authenticatable, :confirmable, | ||
# :lockable, :timeoutable and :omniauthable | ||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :trackable, :validatable | ||
|
||
# Setup accessible (or protected) attributes for your model | ||
attr_accessible :email, :password, :password_confirmation, :remember_me | ||
# attr_accessible :title, :body | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Resend confirmation instructions | ||
= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Resend confirmation instructions" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
p | ||
| Welcome #{@resource.email}! | ||
p You can confirm your account email through the link below: | ||
p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
p | ||
| Hello #{@resource.email}! | ||
p Someone has requested a link to change your password, and you can do this through the link below. | ||
p= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) | ||
p If you didn't request this, please ignore this email. | ||
p Your password won't change until you access the link above and create a new one. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
p | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lock 和 unlock 的也不用了。 |
||
| Hello #{@resource.email}! | ||
p Your account has been locked due to an excessive amount of unsuccessful sign in attempts. | ||
p Click the link below to unlock your account: | ||
p= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
h2 Change your password | ||
= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| | ||
= devise_error_messages! | ||
= f.hidden_field :reset_password_token | ||
div | ||
= f.label :password, "New password" | ||
br/ | ||
= f.password_field :password | ||
div | ||
= f.label :password_confirmation, "Confirm new password" | ||
br/ | ||
= f.password_field :password_confirmation | ||
div= f.submit "Change my password" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Forgot your password? | ||
= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Send me reset password instructions" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
h2 | ||
| Edit #{resource_name.to_s.humanize} | ||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
i (leave blank if you don't want to change it) | ||
br/ | ||
= f.password_field :password, :autocomplete => "off" | ||
div | ||
= f.label :password_confirmation | ||
br/ | ||
= f.password_field :password_confirmation | ||
div | ||
= f.label :current_password | ||
i (we need your current password to confirm your changes) | ||
br/ | ||
= f.password_field :current_password | ||
div= f.submit "Update" | ||
h3 Cancel my account | ||
p | ||
| Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete}. | ||
= link_to "Back", :back |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
h2 Sign up | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 注册放在首页了,这个文件可以清理 |
||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
br/ | ||
= f.password_field :password | ||
div | ||
= f.label :password_confirmation | ||
br/ | ||
= f.password_field :password_confirmation | ||
div= f.submit "Sign up" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
h2 Sign in | ||
= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
br/ | ||
= f.password_field :password | ||
- if devise_mapping.rememberable? | ||
div | ||
= f.check_box :remember_me | ||
= f.label :remember_me | ||
div= f.submit "Sign in" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- if controller_name != 'sessions' | ||
= link_to "Sign in", new_session_path(resource_name) | ||
br/ | ||
- if devise_mapping.registerable? && controller_name != 'registrations' | ||
= link_to "Sign up", new_registration_path(resource_name) | ||
br/ | ||
- if devise_mapping.recoverable? && controller_name != 'passwords' | ||
= link_to "Forgot your password?", new_password_path(resource_name) | ||
br/ | ||
- if devise_mapping.confirmable? && controller_name != 'confirmations' | ||
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) | ||
br/ | ||
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' | ||
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) | ||
br/ | ||
- if devise_mapping.omniauthable? | ||
- resource_class.omniauth_providers.each do |provider| | ||
= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) | ||
br/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Resend unlock instructions | ||
= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Resend unlock instructions" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,13 @@ | |
h1 = t('slogan.title') | ||
p = t('slogan.description') | ||
.span5.offset2 | ||
form.login | ||
label = t('label.nickname') | ||
form.login action="/users" accept-charset="UTF-8" id="new_user" method="post" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /users 改成 helper |
||
= devise_error_messages! | ||
input type="text" placeholder=t('label.nickname') | ||
label = t('label.email_address') | ||
input type="text" placeholder=t('label.email_address') | ||
label = t('label.password') | ||
input type="password" placeholder=t('label.password') | ||
|
||
button.btn type="submit" = t('label.sign_up') | ||
input#user_email name="user[email]" size="30" type="email" placeholder=t('label.email_address') | ||
input#user_password name="user[password]" size="30" type="password" placeholder=t('label.password') | ||
input#user_password_confirmation name="user[password_confirmation]" size="30" type="password" placeholder=t('label.password_confirmation') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 确认密码可以不用了,如果用户输出,登录时还可以通过「忘记密码」找回来。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的,这里修改一下 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我又考虑了一下,是否叫username更合适一些,login有时有动词的意思。或者loginname There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 就叫 username |
||
input.btn.btn-success name="commit" type="submit" value="#{t('label.sign_up')}" | ||
|
||
.row-fluid | ||
.span3 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Resend confirmation instructions | ||
= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Resend confirmation instructions" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
p | ||
| Welcome #{@resource.email}! | ||
p You can confirm your account email through the link below: | ||
p= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
p | ||
| Hello #{@resource.email}! | ||
p Someone has requested a link to change your password, and you can do this through the link below. | ||
p= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) | ||
p If you didn't request this, please ignore this email. | ||
p Your password won't change until you access the link above and create a new one. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
p | ||
| Hello #{@resource.email}! | ||
p Your account has been locked due to an excessive amount of unsuccessful sign in attempts. | ||
p Click the link below to unlock your account: | ||
p= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
h2 Change your password | ||
= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| | ||
= devise_error_messages! | ||
= f.hidden_field :reset_password_token | ||
div | ||
= f.label :password, "New password" | ||
br/ | ||
= f.password_field :password | ||
div | ||
= f.label :password_confirmation, "Confirm new password" | ||
br/ | ||
= f.password_field :password_confirmation | ||
div= f.submit "Change my password" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Forgot your password? | ||
= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Send me reset password instructions" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
h2 | ||
| Edit #{resource_name.to_s.humanize} | ||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
i (leave blank if you don't want to change it) | ||
br/ | ||
= f.password_field :password, :autocomplete => "off" | ||
div | ||
= f.label :password_confirmation | ||
br/ | ||
= f.password_field :password_confirmation | ||
div | ||
= f.label :current_password | ||
i (we need your current password to confirm your changes) | ||
br/ | ||
= f.password_field :current_password | ||
div= f.submit "Update" | ||
h3 Cancel my account | ||
p | ||
| Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete}. | ||
= link_to "Back", :back |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
h2 Sign up | ||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
br/ | ||
= f.password_field :password | ||
div | ||
= f.label :password_confirmation | ||
br/ | ||
= f.password_field :password_confirmation | ||
div= f.submit "Sign up" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
h2 Sign in | ||
= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div | ||
= f.label :password | ||
br/ | ||
= f.password_field :password | ||
- if devise_mapping.rememberable? | ||
div | ||
= f.check_box :remember_me | ||
= f.label :remember_me | ||
div= f.submit "Sign in" | ||
= render "devise/shared/links" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- if controller_name != 'sessions' | ||
= link_to "Sign in", new_session_path(resource_name) | ||
br/ | ||
- if devise_mapping.registerable? && controller_name != 'registrations' | ||
= link_to "Sign up", new_registration_path(resource_name) | ||
br/ | ||
- if devise_mapping.recoverable? && controller_name != 'passwords' | ||
= link_to "Forgot your password?", new_password_path(resource_name) | ||
br/ | ||
- if devise_mapping.confirmable? && controller_name != 'confirmations' | ||
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) | ||
br/ | ||
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' | ||
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) | ||
br/ | ||
- if devise_mapping.omniauthable? | ||
- resource_class.omniauth_providers.each do |provider| | ||
= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) | ||
br/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
h2 Resend unlock instructions | ||
= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| | ||
= devise_error_messages! | ||
div | ||
= f.label :email | ||
br/ | ||
= f.email_field :email | ||
div= f.submit "Resend unlock instructions" | ||
= render "devise/shared/links" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要 confirmable,注册成功后要给用户发邮件激活。以后发邮件给用户不容易进垃圾箱。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分以后会实现