Save username and password after successful auth

This commit is contained in:
Vegetto 2021-01-17 20:19:52 -08:00
parent 593a017c78
commit c36350a593

View File

@ -111,11 +111,18 @@ function CreateSigninGroup(user = "")
username_field.label = tr("Username") username_field.label = tr("Username")
username_field.field = "username" username_field.field = "username"
username_field.type = "string" username_field.type = "string"
username_field.value = user if user = "" and get_setting("username") <> invalid
username_field.value = get_setting("username")
else
username_field.value = user
end if
password_field = CreateObject("roSGNode", "ConfigData") password_field = CreateObject("roSGNode", "ConfigData")
password_field.label = tr("Password") password_field.label = tr("Password")
password_field.field = "password" password_field.field = "password"
password_field.type = "password" password_field.type = "password"
if get_setting("password") <> invalid
password_field.value = get_setting("password")
end if
items = [ username_field, password_field ] items = [ username_field, password_field ]
config.configItems = items config.configItems = items
@ -143,7 +150,11 @@ function CreateSigninGroup(user = "")
if node = "submit" if node = "submit"
' Validate credentials ' Validate credentials
get_token(username.value, password.value) get_token(username.value, password.value)
if get_setting("active_user") <> invalid then return "true" if get_setting("active_user") <> invalid
set_setting("username", username.value)
set_setting("password", password.value)
return "true"
end if
print "Login attempt failed..." print "Login attempt failed..."
group.findNode("alert").text = tr("Login attempt failed.") group.findNode("alert").text = tr("Login attempt failed.")
end if end if