Commit 3a6d40ad authored by Cédric Bellegarde's avatar Cédric Bellegarde

Rework credentials backend

parent 0f9bc79c
Pipeline #51605 passed with stage
in 10 minutes and 22 seconds
......@@ -14,7 +14,7 @@ from gi.repository import WebKit2WebExtension, GLib, GObject
from urllib.parse import urlparse
from eolie.define import Type, App
from eolie.define import App
from eolie.helper_passwords import PasswordsHelper
from eolie.logger import Logger
......@@ -198,52 +198,36 @@ class FormsExtension(GObject.Object):
@param page_id as int
"""
try:
uuid = None
# Check if login is the same and password changed
if attributes is not None:
# New username if nothing already set
if attributes["login"] != user_form_value and \
self.__pending_credentials is None:
uuid = ""
# New password
elif attributes["login"] == user_form_value and\
password != pass_form_value:
uuid = attributes["uuid"]
# Nothing to do
elif attributes["login"] == user_form_value and\
password == pass_form_value:
self.__pending_credentials = Type.NONE
if uuid is not None and\
self.__pending_credentials != Type.NONE:
self.__pending_credentials = (
uuid,
user_form_name,
user_form_value,
pass_form_name,
pass_form_value,
hostname_uri,
form_uri)
# Last found credentials
self.__pending_credentials = (user_form_name,
user_form_value,
pass_form_name,
pass_form_value,
hostname_uri,
form_uri)
# New credential
if count == 0:
args = ("", user_form_name, user_form_value,
pass_form_name, hostname_uri, form_uri)
variant = GLib.Variant.new_tuple(GLib.Variant("(ssssss)",
args))
self.emit("submit-form", variant)
# Last credential
elif index == count - 1:
if self.__pending_credentials not in [None, Type.NONE]:
(uuid,
user_form_name,
user_form_value,
pass_form_name,
pass_form_value,
hostname_uri,
form_uri) = self.__pending_credentials
args = (uuid, user_form_name, user_form_value,
pass_form_name, hostname_uri, form_uri)
variant = GLib.Variant.new_tuple(GLib.Variant("(ssssss)",
args))
self.emit("submit-form", variant)
if attributes is not None:
uuid = attributes["uuid"]
# No password change
if attributes["login"] == user_form_value and\
password == pass_form_value:
return
# New password
elif attributes["login"] != user_form_value:
uuid = ""
args = (uuid, user_form_name, user_form_value,
pass_form_name, hostname_uri, form_uri)
variant = GLib.Variant.new_tuple(GLib.Variant("(ssssss)",
args))
self.emit("submit-form", variant)
except Exception as e:
Logger.error("FormsExtension::__on_get_password(): %s", e)
......
......@@ -16,7 +16,7 @@ from gi.repository import Gio, GLib, WebKit2WebExtension
from urllib.parse import urlparse
from uuid import uuid4
from eolie.define import PROXY_BUS, PROXY_PATH, Type
from eolie.define import PROXY_BUS, PROXY_PATH
from eolie.list import LinkedList
from eolie.helper_passwords import PasswordsHelper
from eolie.logger import Logger
......@@ -202,11 +202,10 @@ class ProxyExtensionServer(Server):
@param hostname_uri as str
@param form_uri as str
"""
if self.__form_extension.pending_credentials in [None, Type.NONE]:
if self.__form_extension.pending_credentials is None:
return
try:
(_uuid,
_user_form_name,
(_user_form_name,
user_form_value,
_pass_form_name,
pass_form_value,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment