Sha256: f32abf921db63505bd73b2d40899012d72f5bf1b67134bc15431b93b828b19f8
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# code: # * George Moschovitis # # (c) 2004 Navel, all rights reserved. # $Id: autologin.rb 167 2004-11-23 14:03:10Z gmosx $ require "glue/string" require "nitro/server/filters" require_part "users" module N # = AutoLoginFilter # # Automatically login a user with valid authentication cookie. # Uses some n1 code at the moment. # class AutoLoginFilter < N::ServerFilter # Perform the actual work of auto logging in the user # def process(request) if request.is_top? # only try to autologin for top level requests # there is NO need for the older SKIP_AUTOLOGIN session flag. if (request.session.user.anonymous?) and cookie = request.get_cookie($users_auth_cookie) username, password_crypted = cookie.split(",") if user = $og.load_by_name(username, N::User) and password_crypted == user.password if request.session.login(request, user) # user logged in else # stale cookie, remove it request.del_cookie($users_auth_cookie) end else $log.warn "Unknown user or wrong password in auth-cookie: #{cookie} from IP: #{request.remote_addr}" end end end return @next_filter.process(request) if @next_filter end end end # module
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.5.0 | lib/nitro/server/filters/autologin.rb |
nitro-0.6.0 | lib/nitro/server/filters/autologin.rb |
nitro-0.7.0 | lib/nitro/server/filters/autologin.rb |