818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
|
cs = cs + set
ok = iok
end
end
return cs, ok
end
terra srv:actor_auth_pw(ip: lib.store.inet, user: pstring, pw: pstring): uint64
for i=0,self.sources.ct do
if self.sources(i).backend ~= nil and
self.sources(i).backend.actor_auth_pw ~= nil then
var aid,uid,newhnd = self.sources(i):actor_auth_pw(ip,user,pw)
if aid ~= 0 then
if uid == 0 then
lib.dbg('new user just logged in, creating account entry')
var kbuf: uint8[lib.crypt.const.maxdersz]
var na = lib.store.actor.mk(&kbuf[0])
na.handle = newhnd.ptr
var newuid: uint64
if self.sources(i).backend.actor_create ~= nil then
newuid = self.sources(i):actor_create(&na)
else newuid = self:actor_create(&na) end
if self.sources(i).backend.actor_auth_register_uid ~= nil then
self.sources(i):actor_auth_register_uid(aid,newuid)
end
end
return aid
end
end
end
return 0
end
terra cfgcache.methods.load :: {&cfgcache} -> {}
terra cfgcache:init(o: &srv)
self.overlord = o
self:load()
end
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
cs = cs + set
ok = iok
end
end
return cs, ok
end
local function mk_auth_fn(suffix,...)
local syms = {...}
local name = 'actor_auth_' .. suffix
srv.methods[name] = terra(self: &srv, ip: lib.store.inet, user: pstring, [syms]): uint64
for i=0,self.sources.ct do
if self.sources(i).backend ~= nil and
self.sources(i).backend.[name] ~= nil then
var aid,uid,newhnd = self.sources(i):[name](ip,user, [syms])
if aid ~= 0 then
if uid == 0 then
lib.dbg('new user just logged in, creating account entry')
var kbuf: uint8[lib.crypt.const.maxdersz]
var na = lib.store.actor.mk(&kbuf[0])
na.handle = newhnd.ptr
var newuid: uint64
if self.sources(i).backend.actor_create ~= nil then
newuid = self.sources(i):actor_create(&na)
else newuid = self:actor_create(&na) end
if self.sources(i).backend.actor_auth_register_uid ~= nil then
self.sources(i):actor_auth_register_uid(aid,newuid)
end
end
return aid
end
end
end
return 0
end
srv.methods[name].name = name
end
mk_auth_fn('pw', symbol(pstring))
mk_auth_fn('challenge', symbol(lib.mem.ptr(uint8)), symbol(pstring))
--terra srv:actor_auth_pw(ip: lib.store.inet, user: pstring, pw: pstring): uint64
-- for i=0,self.sources.ct do
-- if self.sources(i).backend ~= nil and
-- self.sources(i).backend.actor_auth_pw ~= nil then
-- var aid,uid,newhnd = self.sources(i):actor_auth_pw(ip,user,pw)
-- if aid ~= 0 then
-- if uid == 0 then
-- lib.dbg('new user just logged in, creating account entry')
-- var kbuf: uint8[lib.crypt.const.maxdersz]
-- var na = lib.store.actor.mk(&kbuf[0])
-- na.handle = newhnd.ptr
-- var newuid: uint64
-- if self.sources(i).backend.actor_create ~= nil then
-- newuid = self.sources(i):actor_create(&na)
-- else newuid = self:actor_create(&na) end
--
-- if self.sources(i).backend.actor_auth_register_uid ~= nil then
-- self.sources(i):actor_auth_register_uid(aid,newuid)
-- end
-- end
-- return aid
-- end
-- end
-- end
--
-- return 0
--end
terra cfgcache.methods.load :: {&cfgcache} -> {}
terra cfgcache:init(o: &srv)
self.overlord = o
self:load()
end
|