Merge pull request #838 from 26F-Studio/ci-api-new
Ci api new close #821
This commit is contained in:
60
parts/scenes/login.lua
Normal file
60
parts/scenes/login.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
local scene={}
|
||||
|
||||
local function _authorize()
|
||||
love.system.openURL("https://dev.studio26f.org/oauth?product=techmino")
|
||||
end
|
||||
local function _submit()
|
||||
local tickets=scene.widgetList.ticket:getText():upper()
|
||||
if #tickets~=128 then
|
||||
MES.new('error',text.wrongCode)
|
||||
else
|
||||
USER.aToken=tickets:sub(1,64)
|
||||
USER.oToken=tickets:sub(65)
|
||||
NET.login()
|
||||
end
|
||||
end
|
||||
local function _paste()
|
||||
local t=love.system.getClipboardText()
|
||||
if t then
|
||||
t=STRING.trim(t)
|
||||
if #t==128 and t:match("[0-9A-Z]+") then
|
||||
scene.widgetList.ticket:setText(t)
|
||||
return
|
||||
end
|
||||
end
|
||||
MES.new('error',text.wrongCode)
|
||||
end
|
||||
|
||||
function scene.enter()
|
||||
scene.widgetList.ticket:clear()
|
||||
end
|
||||
|
||||
function scene.keyDown(key,rep)
|
||||
if key=='escape' and not rep then
|
||||
SCN.back()
|
||||
elseif key=='return' or key=='kpenter' then
|
||||
if #scene.widgetList.ticket:getText()==0 then
|
||||
_authorize()
|
||||
else
|
||||
_submit()
|
||||
end
|
||||
elseif key=='v' and love.keyboard.isDown('lctrl','rctrl') then
|
||||
_paste()
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
|
||||
|
||||
WIDGET.newInputBox{name='ticket', x=280, y=200,w=730,h=320,font=30,regex="[0-9A-Z]",limit=128},
|
||||
|
||||
WIDGET.newKey{name='authorize', x=430, y=600,w=300,h=80,font=40,code=_authorize},
|
||||
WIDGET.newKey{name='submit', x=755, y=600,w=300,h=80,font=40,code=_submit},
|
||||
WIDGET.newKey{name='paste', x=970, y=600,w=80,font=40,fText=CHAR.icon.import,code=_paste},
|
||||
|
||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
|
||||
}
|
||||
|
||||
return scene
|
||||
@@ -1,67 +0,0 @@
|
||||
local scene={}
|
||||
|
||||
local function _getCode()
|
||||
local email=scene.widgetList.email:getText()
|
||||
if not STRING.simpEmailCheck(email) then
|
||||
MES.new('error',text.wrongEmail)
|
||||
else
|
||||
USER.email=email
|
||||
NET.getCode(email)
|
||||
end
|
||||
end
|
||||
local function _codeLogin()
|
||||
local code=scene.widgetList.code:getText():upper()
|
||||
if #code~=8 then
|
||||
MES.new('error',text.wrongCode)
|
||||
else
|
||||
NET.codeLogin(USER.email,code)
|
||||
end
|
||||
end
|
||||
local function _paste()
|
||||
local t=love.system.getClipboardText()
|
||||
if t then
|
||||
t=STRING.trim(t)
|
||||
if #t==8 and t:match("[0-9]+") then
|
||||
scene.widgetList.code:setText(t)
|
||||
return
|
||||
end
|
||||
end
|
||||
MES.new('warn',text.wrongCode)
|
||||
end
|
||||
|
||||
function scene.enter()
|
||||
scene.widgetList.email:setText(USER.email or "")
|
||||
scene.widgetList.code:clear()
|
||||
end
|
||||
|
||||
function scene.keyDown(key,rep)
|
||||
if key=='escape' and not rep then
|
||||
SCN.back()
|
||||
elseif key=='return' or key=='kpenter' then
|
||||
if #scene.widgetList.code:getText():upper()==0 then
|
||||
_getCode()
|
||||
else
|
||||
_codeLogin()
|
||||
end
|
||||
elseif key=='v' and love.keyboard.isDown('lctrl','rctrl') then
|
||||
_paste()
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
|
||||
WIDGET.newButton{name='login_pw', x=1080,y=100,w=260,h=80,color='lY',code=function() SCN.swapTo('login_pw','swipeR') end},
|
||||
|
||||
WIDGET.newInputBox{name='email', x=380, y=200,w=626,h=60,limit=128},
|
||||
WIDGET.newKey{name='send', x=640, y=330,w=300,h=80,font=40,code=_getCode},
|
||||
|
||||
WIDGET.newInputBox{name='code', x=380, y=400,w=626,h=60,regex="[0-9a-zA-Z]",limit=8},
|
||||
WIDGET.newKey{name='verify', x=640, y=530,w=300,h=80,font=40,code=_codeLogin},
|
||||
WIDGET.newKey{name='paste', x=850, y=530,w=80,font=40,fText=CHAR.icon.import,code=_paste},
|
||||
|
||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
|
||||
}
|
||||
|
||||
return scene
|
||||
@@ -1,44 +0,0 @@
|
||||
local emailBox=WIDGET.newInputBox{name='email',x=380,y=200,w=500,h=60,limit=128}
|
||||
local passwordBox=WIDGET.newInputBox{name='password',x=380,y=300,w=620,h=60,secret=true,regex="[ -~]",limit=64}
|
||||
|
||||
local showEmail=true
|
||||
|
||||
local function _login()
|
||||
local email,password=emailBox:getText(),passwordBox:getText()
|
||||
if not STRING.simpEmailCheck(email) then
|
||||
MES.new('error',text.wrongEmail) return
|
||||
elseif #password==0 then
|
||||
MES.new('error',text.noPassword) return
|
||||
end
|
||||
NET.pwLogin(email,password)
|
||||
end
|
||||
|
||||
local scene={}
|
||||
|
||||
function scene.enter()
|
||||
showEmail=false
|
||||
emailBox.secret=true
|
||||
emailBox:setText(USER.email)
|
||||
passwordBox:setText("")
|
||||
end
|
||||
|
||||
function scene.keyDown(key,rep)
|
||||
if rep then return true end
|
||||
if key=='return' then
|
||||
_login()
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
|
||||
WIDGET.newButton{name='login_mail',x=1080,y=100,w=260,h=80,color='lY',code=function() SCN.swapTo('login_mail','swipeL') end},
|
||||
emailBox,
|
||||
passwordBox,
|
||||
WIDGET.newSwitch{name='showEmail', x=550, y=420,disp=function() return showEmail end,code=function() showEmail=not showEmail emailBox.secret=not showEmail end},
|
||||
WIDGET.newKey{name='login', x=1140,y=540,w=170,h=80,font=40,code=pressKey'return'},
|
||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||
}
|
||||
|
||||
return scene
|
||||
@@ -76,7 +76,7 @@ function scene.keyDown(key,isRep)
|
||||
end
|
||||
elseif key=='a' then
|
||||
if _testButton(3) then
|
||||
NET.autoLogin()
|
||||
NET.login(true)
|
||||
end
|
||||
elseif key=='z' then
|
||||
if _testButton(4) then
|
||||
|
||||
@@ -18,15 +18,13 @@ scene.widgetList={
|
||||
WIDGET.newButton{name='league',x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'},
|
||||
WIDGET.newButton{name='ffa', x=640, y=360,w=350,h=120,font=40,color='D',code=function() MES.new('warn',text.notFinished)--[[NET.enterRoom({name='ffa'})]] end},
|
||||
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
|
||||
WIDGET.newButton{name='resetPW',x=680,y=40,w=180,h=60,color='dG',code=goScene'reset_password'},
|
||||
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
|
||||
code=function()
|
||||
if tryBack() then
|
||||
print('logout')
|
||||
USER.__data.uid=false
|
||||
USER.__data.email=false
|
||||
USER.__data.password=false
|
||||
USER.__data.rToken=false
|
||||
USER.__data.aToken=false
|
||||
USER.__data.oToken=false
|
||||
love.filesystem.remove('conf/user')
|
||||
SCN.back()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user