92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/jungle_path/api/helpers/auth_local_user.rb', line 92
def get_assumed_user user_name, no_cache=false
cache_key = "#{user_name}.password"
user = cache[cache_key]
if user == nil or no_cache
lowercase_user_name = nil
lowercase_user_name = user_name.downcase if user_name
ds = db.base['select id, user_name, name, first_name, last_name, phone, email, hash, key, active from "user" where user_name = ? or email = ?', lowercase_user_name, lowercase_user_name]
hash = ds.first
user = Schema::User.new(hash, false) if hash
halt 401, "Unauthorized" unless user
halt 401, "Unauthorized: user #{user.user_name} is not marked as active." unless user.active
user.is_valid = true
cache[cache_key] = user if user
end
user
end
|