Permalink
Browse files

Exercise9.6.2 done

  • Loading branch information...
ilyacherevkov committed Feb 28, 2012
1 parent f58c785 commit 312fdf7c6c5e5053c08b9f6a0a12258fc317480d
@@ -29,6 +29,7 @@ def create
else
@title = "Регистрация"
render 'new'
+ @user.password = nil
end
end
@@ -2,12 +2,14 @@
module SessionsHelper
def sign_in(user)
- cookies.permanent.signed[:remember_token] = [user.id, user.salt]
+ #cookies.permanent.signed[:remember_token] = [user.id, user.salt]
+ session[:user_id] = user.id
self.current_user = user
end
def current_user
- @current_user ||= user_from_remember_token
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ #@current_user ||= user_from_remember_token
end
def current_user=(user)
@@ -19,7 +21,8 @@ def signed_in?
end
def sign_out
- cookies.delete(:remember_token)
+ #cookies.delete(:remember_token)
+ session[:user_id] = nil
self.current_user = nil
end
@@ -39,19 +42,19 @@ def current_user?(user)
private
- def user_from_remember_token
- User.authenticate_with_salt(*remember_token)
- end
+ #def user_from_remember_token
+ # User.authenticate_with_salt(*remember_token)
+ #end
- def remember_token
- cookies.signed[:remember_token] || [nil, nil]
- end
+ #def remember_token
+ # cookies.signed[:remember_token] || [nil, nil]
+ #end
- def store_location
- session[:return_to] = request.fullpath
- end
+ #def store_location
+ # session[:return_to] = request.fullpath
+ #end
- def clear_return_to
- session[:return_to] = nil
- end
+ #def clear_return_to
+ # session[:return_to] = nil
+ #end
end
View
@@ -19,8 +19,8 @@ class User < ActiveRecord::Base
validates :name, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
- :format => { :with => email_regex },
- :uniqueness => { :case_sensitive => false }
+ :format => { :with => email_regex },
+ :uniqueness => { :case_sensitive => false }
validates :password, :presence => true,
:confirmation => true,
:length => { :within => 6..40 }
@@ -10,9 +10,9 @@
<div class="container">
<%= render 'layouts/header' %>
<section class="round">
- <% flash.each do |key, value| %>
- <div class="flash <%= key %>"><%= value %></div>
- <% end %>
+ <% flash.each do |key, value| %>
+ <%= content_tag(:div, value, :class => "flash #{key}") %>
+ <% end %>
<%= yield %>
</section>
<%= render 'layouts/footer' %>

0 comments on commit 312fdf7

Please sign in to comment.