Updating user.rb with door_access_url variables
This commit is contained in:
parent
f3443a3a82
commit
d73ea31625
|
@ -12,9 +12,14 @@ class User < ActiveRecord::Base
|
||||||
attr_accessible :card_id, :card_number, :card_permissions, :name
|
attr_accessible :card_id, :card_number, :card_permissions, :name
|
||||||
validates_uniqueness_of :card_id, :card_number
|
validates_uniqueness_of :card_id, :card_number
|
||||||
|
|
||||||
|
|
||||||
def upload_to_door
|
def upload_to_door
|
||||||
# do shit here
|
# load config values
|
||||||
source = open("http://192.168.1.177?e=1234").read
|
door_access_url = APP_CONFIG['door_access_url']
|
||||||
|
door_access_password = APP_CONFIG['door_access_password']
|
||||||
|
|
||||||
|
# connect to door access system
|
||||||
|
source = open("#{door_access_url}?e=#{door_access_password}").read
|
||||||
results = source.scan(/authok/)
|
results = source.scan(/authok/)
|
||||||
if(results.size > 0) then
|
if(results.size > 0) then
|
||||||
#only continue if we've got an OK login
|
#only continue if we've got an OK login
|
||||||
|
@ -22,11 +27,11 @@ class User < ActiveRecord::Base
|
||||||
userperm = self.card_permissions.to_s.rjust(3, '0')
|
userperm = self.card_permissions.to_s.rjust(3, '0')
|
||||||
cardnum = self.card_number.rjust(8, '0')
|
cardnum = self.card_number.rjust(8, '0')
|
||||||
|
|
||||||
source = open("http://192.168.1.177?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
source = open("#{door_access_url}?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
||||||
results = source.scan(/cur/)
|
results = source.scan(/cur/)
|
||||||
|
|
||||||
#logout
|
#logout
|
||||||
open("http://192.168.1.177?e=0000")
|
open("#{door_access_url}?e=0000")
|
||||||
|
|
||||||
if(results.size > 0) then
|
if(results.size > 0) then
|
||||||
#only return true if we got some kind of decent response
|
#only return true if we got some kind of decent response
|
||||||
|
@ -45,7 +50,11 @@ class User < ActiveRecord::Base
|
||||||
@users = User.all
|
@users = User.all
|
||||||
@end_results = Array.new
|
@end_results = Array.new
|
||||||
|
|
||||||
source = open("http://192.168.1.177?e=1234").read
|
# load config values
|
||||||
|
door_access_url = APP_CONFIG['door_access_url']
|
||||||
|
door_access_password = APP_CONFIG['door_access_password']
|
||||||
|
|
||||||
|
source = open("#{door_access_url}?e=#{door_access_password}").read
|
||||||
results = source.scan(/authok/)
|
results = source.scan(/authok/)
|
||||||
if(results.size > 0) then
|
if(results.size > 0) then
|
||||||
@users.each do |u|
|
@users.each do |u|
|
||||||
|
@ -54,7 +63,7 @@ class User < ActiveRecord::Base
|
||||||
userperm = u.card_permissions.to_s.rjust(3, '0')
|
userperm = u.card_permissions.to_s.rjust(3, '0')
|
||||||
cardnum = u.card_number.rjust(8, '0')
|
cardnum = u.card_number.rjust(8, '0')
|
||||||
|
|
||||||
source = open("http://192.168.1.177?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
source = open("#{door_access_url}?m#{usernum}&p#{userperm}&t#{cardnum}").read
|
||||||
results = source.scan(/cur/)
|
results = source.scan(/cur/)
|
||||||
|
|
||||||
if(results.size > 0) then
|
if(results.size > 0) then
|
||||||
|
@ -66,7 +75,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
#logout
|
#logout
|
||||||
open("http://192.168.1.177?e=0000")
|
open("#{door_access_url}?e=0000")
|
||||||
else
|
else
|
||||||
@end_results.push([usernum,"FAIL"])
|
@end_results.push([usernum,"FAIL"])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user