Displaying 20 results from an estimated 26 matches for "remember_token".
2010 Sep 03
1
Action Controller Error: undefined local variable or method `current_user'
...s_layouts__header_html_erb___1701013666_2174344740_524030''
app/views/layouts/application.html.erb:10:in
`_app_views_layouts_application_html_erb__1439570095_2174436720_0''
---- END
sessions_helper.rb CODE:
module SessionsHelper
def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.salt]
current_user = user
end
def current_user=(user)
@current_user = user
end
def signed_in?
!current_user.nil?
end
def sign_out
cookies.delete(:remember_token)
self.current_user = nil
end
private
def user_from_remember_token
User.aut...
2012 May 12
12
before_save messing up
#user.rb ------> Model
class User < ActiveRecord::Base
attr_accessible :email, :name, :password, :password_confirmation
has_secure_password
before_save :create_remember_token
.
.
.
.
.
.
.
private
def create_remember_token
self.remember_token = SecureRandom.urlsafe_base64
end
end
#sessions_controller.rb -------> Sessions Controller
class SessionsController < ApplicationController
def new
end...
2011 Feb 05
4
Questions about Chapter 9: Sign in, Sign out of RoR Tutorial | Learn Rails by Example
...al, Modules are used instead of creating a Model and
working in a class inside a module , like in authenticating passwords.
Wouldn''t that be possible? Or is it unnecessary since we''re not
messing with a database in terms of storing data?
2. what is the difference between session[:remember_token] = user.id
and cookies[:remember_token] ?
Session stores the cookie locally until we exit the browser and then
it gets deleted whereas cookies is permanent stored even after we exit
the browser?
3. In section 9.3.3 we are being introduced to the curent user with
the code in the module SessionsHelp...
2007 Oct 04
1
Cookies in RSpec
So how do you work with cookies properly in rspec now? I noticed in
the docs that it mentions session, assigns, and flash, but nothing of
cookie. I''m using edge rails so I''m concerned about changes to the
cookie mechanisms. I need to assign values into the cookie (a
remember token for restful authentication) so that I can have it log
in by cookie. here is my spec
2008 Jan 30
2
Where can I get "authenticate_with_http_basic"?
..._http_basic do |username, password|
self.current_user = User.authenticate(username, password)
end
end
# Called from #current_user. Finaly, attempt to login by an
expiring token in the cookie.
def login_from_cookie
user = cookies[:auth_token] &&
User.find_by_remember_token(cookies[:auth_token])
if user && user.remember_token?
user.remember_me
cookies[:auth_token] = { :value =>
user.remember_token, :expires => user.remember_token_expires_at }
self.current_user = user
end
end
end
==========================end authen...
2008 Aug 01
0
Help with Access Control
...ssword(crypted_password,
login.salt)
if login.crypted_password != expected_password
login = nil
end
end
login
end
def password
@password
end
def password=(pw)
@password = pw
create_new_salt
self.crypted_password = User.encrypted_password(self.password,
self.salt)
end
def remember_token?
remember_token_expires_at && Time.now.utc <
remember_token_expires_at
end
# These create and unset the fields required for remembering users
between browser closes
def remember_me
self.remember_token_expires_at = 2.weeks.from_now.utc
self.remember_token = encrypt(&quo...
2008 Jun 29
3
Working around/with Restful Authentication
...n8tE+Mx9DRM@public.gmane.org'', :password => ''123456'', :password_confirmation => ''123456'')
=> #<User id: nil, login: nil, email: "user-n8tE+Mx9DRM@public.gmane.org",
crypted_password: nil, salt: nil, created_at: nil, updated_at: nil,
remember_token: nil, remember_token_expires_at: nil, activation_code:
nil, activated_at: nil, is_seller: false>
>> u.save
=> false
Any clues as to how I could create a user without actually being sent
to the user controller''s create action? The before_save and
before_create actions are priva...
2007 Dec 16
2
restful_authentication: update of users' attributes on every page load upon 'Remember me' being enabled?
Hello there,
I just noticed a kinda weird thing: if users log in with the ''Remember
Me'' option enabled, their records in the db get updated everytime the
user reloads a page, because apparently restful_authentication''s code
updates the remember_token_expires_at & remember_token attributes for
each page load (not only once on the actual login (from cookie).
Wouldn''t it make much more sense to set this remember_token_expires_at
and the corresponding token once only and that''s it? Or am I missing
something?
Just wanna make...
2011 Jul 30
22
Question about Helpers
Studying the RoR 3 Tutorial book by Michael Hartl
and on page 345 there''s the code inside the SessionsHelper:
_________________________________________________________
module SessionsHelper
def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.sault]
self.current_user = user
end
end
__________________________________________________________
What is the purpose of "self" inside the session helper?
I know that inside a model it refers to the class object.
For example
Class User < ActiveRecord::Base
self.sa...
2014 Jun 08
0
Re-render partial inside a modal
...users", :action =>"new" %>
<a class="close-reveal-modal">×</a>
</div>
*In my Users.controller.rb, I am rendering new sign up page if user inputs
incorrect information! *
def create
@user = User.new(user_params)
if @user.save
# session[:remember_token] = @user.id
# @current_user = @user
# session[:remember_token] = @user.id.to_s
flash.now[:success] = "You have succesfully signed up!"
redirect_to users_path
else
render 'new'
end
end
*What I actually want to accomplish is rerendering the partial inside the
modal...
2006 Aug 07
1
''Remember me'' in acts_as_authenticated troubles
Hi there
I''m having trouble getting the ''remember me'' functionality going in
acts_as_authenticated.
The issue seems to be that the login_from_cookie method is using only
the first 60 characters of the remember_token string in the database,
whereas the string in the db is 75 characters long.
I can see in my dev log that login_from_cookie is trying to find the
user but using a truncated string to do so.
Any clues how to rememdy this would be appreciated.
Richard Sandilands
2008 Sep 12
1
restful_authentication rspec failures "Mysql::Error: Incorrect datetime value:"
...ate authenticated User Sessions
rake db:migrate # 288 examples, 193 failures
1)
ActiveRecord::StatementInvalid in ''SessionsController on signout
redirects me to the home page''
Mysql::Error: Incorrect datetime value: ''2008-09-13 21:22:52 UTC'' for
column ''remember_token_expires_at'' at row 1: INSERT INTO `users`
(`salt`, `updated_at`, `crypted_password`,
`remember_token_expires_at`, `id`, `remember_token`, `login`,
`created_at`, `email`) VALUES
(''356a192b7913b04c54574d18c28d46e6395428ab'', ''2008-09-12 21:22:52'',
''...
2008 Jun 20
15
before_save model callback rspec testing
hi all,
i''m learning rspec and i can''t figure out how to test if a callback is
executed in a model.
my model code is:
class User < ActiveRecord::Base
before_save :encrypt_password
...
def encrypt(password)
self.class.encrypt(password, salt)
end
thanks a lot,
cs.
--
Posted via http://www.ruby-forum.com/.
2007 Jul 18
3
Help. Acts_as_Authenticated plugin stops working for me?
...hod `activation_code'' for #<User:0x3b6dbd
@errors=#<ActiveRecord::Errors:0x1a1a1c6 @errors={}, @base=#<User:
0x3b6dbd ...>>,
@attributes={"salt"=>"d580c223adee13c8723434e3987a0787ad124e5b",
"updated_at"=>Wed Jul 18 02:47:19 BST 2007,
"remember_token_expires_at"=>nil,
"crypted_password"=>"78dfec22ed3e7418647c7e90e22d0e4e93c5f375",
"id"=>6, "remember_token"=>nil, "email"=>"erv2-7Ts6kVb0ZJk@public.gmane.org",
"login"=>"erv2", "created_at&qu...
2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
...WHERE (`users`.`email`
= ''foo-+RB1Aph5k6s@public.gmane.org'') LIMIT 1
=> #<User id: 2, login: nil, email: "foo-+RB1Aph5k6s@public.gmane.org", crypted_password:
nil, salt: nil, created_at: "2008-02-07 00:48:48", updated_at:
"2008-02-07 00:48:48", remember_token: nil, remember_token_expires_at:
nil, activation_code: nil, activated_at: nil, state: "passive",
deleted_at: nil, password_reset_at: nil, forgot_password_code: nil,
name: nil, beta_code: nil, beta_approved_at: nil>
Thanks,
Glenn
--~--~---------~--~----~------------~-------~--~----~...
2011 Jun 11
1
Having a problem adding a foreign key
...l => false
t.string "encrypted_password", :limit => 128, :default =>
"", :null => false
t.string "password_salt", :default =>
"", :null => false
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"...
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
...scription"=>"", "latitude"=>"", "longitude"=>"",
"currency"=>"AED"}, "commit"=>"Add shop"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE
"users"."remember_token" = ''YykvzJ8PCZ5RFeE_ZomLXg'' LIMIT 1
Shop Load (0.4ms) SELECT "shops".* FROM "shops" WHERE "shops"."user_id"
= 1 LIMIT 1
(0.1ms) BEGIN
(0.1ms) COMMIT
(0.1ms) BEGIN
(0.1ms) ROLLBACK
In rails console:
irb(main):001:0> alice = Use...
2009 Jul 13
6
first app on Dreamhost with Passenger : "rails needs to know your username and password" ?
I am trying to deploy my first rails app with Dreamhost. I ftp''d over
my existing app, turned on Passenger and pointed it to my /public
directory. When I go to ''www.mydomain.com'' I get the ''Ruby on Rails:
Welcome aboard'' default page, including the following:
Getting started
Here’s how to get rolling:
1.
Create your databases and edit
2013 Jul 05
0
Sign in and sign out
...imple app to manage users
in Ruby on Rails.
I read RoR Tutorial
from http://ruby.railstutorial.org/chapters/sign-in-sign-out#top to sign in
and sign out my app. I implemented the same configuration as it said:
*sessions_helper.rb*
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
*sessions_controller.rb*
def destroy
sign_out
redirect_to root_url
end
*application.html.erb*
<%= link_to "Sign out", signout_path, method: "delete" %>
*routes.rb*
match ''/signout'', to: ''sessions#destroy'', via:...
2007 Dec 21
0
db:migrate problem
...ple < ActiveRecord::Migration
def self.up
create_table :people, :force => true do |t|
t.string :login
t.string :email
t.string :crypted_password, :limit => 40
t.string :salt, :limit => 40
t.timestamps
t.string :remember_token
t.datetime :remember_token_expires_at
t.string :openid_url
end
add_index :people, :login
add_index :people, :email
add_index :people, :openid_url
end
...
end
004_drop_login_name:
class DropLoginName < ActiveRecord::Migration
def self.up
remove_index :p...