Skip to content
Browse files

Sign user in upon successful registration

  • Loading branch information...
1 parent d646188 commit 365415fab17b9cf5db331dda29c8e028bed27d93 @leesmith committed Oct 20, 2012
View
3 app/controllers/users_controller.rb
@@ -7,7 +7,8 @@ def new
def create
@user = User.new(params[:user])
if @user.save
- redirect_to sign_in_path, flash: { success: t(:registration) }
+ cookies[:auth_token] = @user.auth_token
+ redirect_to root_path, flash: { success: t(:thanks) }
else
render :new
end
View
2 app/views/application/_flash.html.haml
@@ -0,0 +1,2 @@
+- flash.each do |name, msg|
+ = content_tag :div, msg, id: "flash-#{name}"
View
2 app/views/home/index.html.haml
@@ -1 +1,3 @@
+= render partial: 'flash', locals: { flash: flash }
+
#home= t(:welcome)
View
3 app/views/password_resets/new.html.haml
@@ -1,8 +1,7 @@
%h1= t(:reset_password)
= form_tag [:password_resets], method: :post do
- - flash.each do |name, msg|
- = content_tag :div, msg, id: "flash-#{name}"
+ = render partial: 'flash', locals: { flash: flash }
%div
= label_tag :email
= email_field_tag :email, params[:email]
View
7 app/views/sessions/new.html.haml
@@ -1,8 +1,7 @@
%h1= t(:sign_in)
= form_tag [:sessions] do
- - flash.each do |name, msg|
- = content_tag :div, msg, id: "flash-#{name}"
+ = render partial: 'flash', locals: { flash: flash }
%div
= label_tag :email
= email_field_tag :email, params[:email]
@@ -11,9 +10,9 @@
= password_field_tag :password
%div
= check_box_tag :remember_me, 1, params[:remember_me]
- = label_tag :remember_me, 'Remember me', id: 'remember-me'
+ = label_tag :remember_me, t(:remember_me), id: 'remember-me'
%div
%strong Help:
- = link_to 'Forgot password?', [:new, :password_reset]
+ = link_to t(:forgot_password), [:new, :password_reset]
%div
= submit_tag t(:sign_in), class: 'button'
View
4 config/locales/en.yml
@@ -6,15 +6,17 @@ en:
invalid_sign_in: 'Invalid sign in attempt!'
not_authenticated: 'Please sign in before continuing!'
register: 'Register'
- registration: 'Registration was successful! You may now sign in.'
+ thanks: 'Thanks for signing up!'
save: 'Save'
sign_in: 'Sign in'
sign_out: 'Sign out'
signed_in_as: 'Signed in as'
successful_sign_out: 'Successfully signed out!'
welcome: 'You have successfully authenticated!'
+ forgot_password: 'Forgot password?'
reset_password: 'Reset Password'
change_password: 'Change Password'
+ remember_me: 'Remember me'
change_password_success: 'Your password was successfully changed!'
reset_email: 'An email was just sent to you with password reset instructions.'
provide_email: 'You must provide an email!'
View
3 spec/integration/user_registers_spec.rb
@@ -30,7 +30,8 @@
fill_in 'Password', with: 'password'
fill_in 'Password confirmation', with: 'password'
click_button 'Register'
- page.should have_content('Registration was successful')
+ page.should have_content('Thanks for signing up')
+ current_path.should == root_path
end
end

0 comments on commit 365415f

Please sign in to comment.
Something went wrong with that request. Please try again.