- ## this section below are for admin account... login properly
- Processing SessionsController#create (for 127.0.0.1 at 2010-06-10 11:38:57) [POS
- T]
- Parameters: {"authenticity_token"=>"MtqhTK+TtkibGKK/q/kYPNeI/kQWhKuY8d316UkL5g
- U=", "Log-In.x"=>"19", "Log-In.y"=>"18", "login"=>"admin", "password"=>"adminpassword"}
- ←[4;35;1mUser Load (16.0ms)←[0m ←[0mSELECT * FROM `users` WHERE (login = 'ad
- min' and activated_at IS NOT NULL) LIMIT 1←[0m
- ←[4;36;1mUser Columns (0.0ms)←[0m ←[0;1mSHOW FIELDS FROM `users`←[0m
- ←[4;35;1mSQL (16.0ms)←[0m ←[0mBEGIN←[0m
- ←[4;36;1mSQL (0.0ms)←[0m ←[0;1mCOMMIT←[0m
- ←[4;35;1mroles_users Columns (78.0ms)←[0m ←[0mSHOW FIELDS FROM `roles_users`
- ←[0m
- ←[4;36;1mRole Load (79.0ms)←[0m ←[0;1mSELECT * FROM `roles` INNER JOIN `role
- s_users` ON `roles`.id = `roles_users`.role_id WHERE (`roles_users`.user_id = 3
- ) ←[0m
- ←[4;35;1mRole Columns (0.0ms)←[0m ←[0mSHOW FIELDS FROM `roles`←[0m
- Redirected to http://127.0.0.1:3000/admin
- Completed in 312ms (DB: 189) | 302 Found [http://127.0.0.1/session]
- 0.0.1/session]
- ←[4;36;1mSQL (0.0ms)←[0m ←[0;1mSET NAMES 'utf8'←[0m
- ←[4;35;1mSQL (0.0ms)←[0m ←[0mSET SQL_AUTO_IS_NULL=0←[0m
- Processing PageController#admin_dashboard (for 127.0.0.1 at 2010-06-10 11:39:01)
- [GET]
- Rendering template within layouts/application
- Rendering page/admin_dashboard
- ←[4;36;1mUser Columns (0.0ms)←[0m ←[0;1mSHOW FIELDS FROM `users`←[0m
- ←[4;35;1mUser Load (16.0ms)←[0m ←[0mSELECT * FROM `users` WHERE (`users`.`id
- ` = 3) LIMIT 1←[0m
- Rendered users/_user_bar (47.0ms)
- Rendered shared/_header_main (47.0ms)
- ←[4;36;1mroles_users Columns (0.0ms)←[0m ←[0;1mSHOW FIELDS FROM `roles_users
- `←[0m
- ←[4;35;1mRole Load (15.0ms)←[0m ←[0mSELECT * FROM `roles` INNER JOIN `roles_
- users` ON `roles`.id = `roles_users`.role_id WHERE (`roles_users`.user_id = 3 )
- ←[0m
- ←[4;36;1mRole Columns (0.0ms)←[0m ←[0;1mSHOW FIELDS FROM `roles`←[0m
- ←[4;35;1mUser Load (15.0ms)←[0m ←[0mSELECT * FROM `users` WHERE (`users`.`id
- ` = 3) ←[0m
- ←[4;36;1mMessage Columns (79.0ms)←[0m ←[0;1mSHOW FIELDS FROM `messages`←[0m
- ←[4;35;1mSQL (156.0ms)←[0m ←[0mSELECT count(*) AS count_all FROM `messages`
- WHERE (((`messages`.`deleted` = 0) AND (`messages`.to_id = 3)) AND (`messages`.t
- o_id = 3)) ←[0m
- Rendered shared/_member_bar (312.0ms)
- Rendered shared/_footer (16.0ms)
- Completed in 984ms (View: 250, DB: 281) | 200 OK [http://127.0.0.1/admin]
- ## this is the member who has an error on login
- Processing SessionsController#create (for 127.0.0.1 at 2010-06-10 11:40:52) [POS
- T]
- Parameters: {"authenticity_token"=>"eiG7z+dwW0m1KaE5XAhJK+PvqjrFNqimS37cGe9jse
- k=", "Log-In.x"=>"0", "Log-In.y"=>"0", "login"=>"gamels", "password"=>"memberpassword"}
- ←[4;35;1mUser Load (0.0ms)←[0m ←[0mSELECT * FROM `users` WHERE (login = 'gam
- els' and activated_at IS NOT NULL) LIMIT 1←[0m
- Failed login for 'gamels' from 127.0.0.1 at Thu Jun 10 03:40:52 UTC 2010
- Rendering template within layouts/application
- Rendering sessions/new
- Rendered shared/_login (16.0ms)
- ←[4;36;1mCity Load (31.0ms)←[0m ←[0;1mSELECT * FROM `cities` ←[0m
- ←[4;35;1mCity Columns (16.0ms)←[0m ←[0mSHOW FIELDS FROM `cities`←[0m
- Rendered shared/_search (531.0ms)
- Rendered users/_user_bar (16.0ms)
- Rendered shared/_header_main (32.0ms)
- Rendered shared/_footer (16.0ms)
- Completed in 781ms (View: 703, DB: 47) | 200 OK [http://127.0.0.1/session]
- ## this is from the code on the app/controllers
- # This controller handles the login/logout function of the site.
- class SessionsController < ApplicationController
- # render new.rhtml
- def new
- @use_alt = true
- end
- def create
- logout_keeping_session!
- user = User.authenticate(params[:login], params[:password])
- if user
- # Protects against session fixation attacks, causes request forgery
- # protection if user resubmits an earlier form using back
- # button. Uncomment if you understand the tradeoffs.
- # reset_session
- self.current_user = user
- new_cookie_flag = (params[:remember_me] == "1")
- handle_remember_cookie! new_cookie_flag
- # redirect_back_or_default('/')
- # flash[:notice] = "Logged in successfully"
- if current_user.has_role?('admin')
- redirect_to admin_path
- elsif current_user.has_role?('member')
- redirect_to member_path
- end
- else
- note_failed_signin
- @login = params[:login]
- @remember_me = params[:remember_me]
- render :action => 'new'
- end
- end
- def destroy
- logout_killing_session!
- flash[:notice] = "You have been logged out."
- redirect_back_or_default('/')
- end
- protected
- # Track failed login attempts
- def note_failed_signin
- flash[:error] = "Couldn't log you in as '#{params[:login]}'"
- logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
- end
- end