Implement logging in via webengine (#160)
Add webview as optional dependency, to login from there, to not have to copy SID manually
This commit is contained in:
parent
affec561c3
commit
7deb4152ac
|
@ -79,9 +79,10 @@ In the [actions](https://github.com/Dummerle/Rare/actions) tab you can find pack
|
|||
|
||||
1. Clone the repo with Submodule: `git clone https://github.com/Dummerle/Rare --recurse-submodules`.
|
||||
2. Change your working directory to the project folder: `cd Rare`
|
||||
3. Run `pip install -r requirements.txt` to install all required dependencies. If you are on Arch you can
|
||||
run `sudo pacman --needed -S python-wheel python-setuptools python-pyqt5 python-qtawesome python-requests python-psutil`
|
||||
4. Run `python3 -m rare`
|
||||
3. Run `pip install -r requirements.txt` to install all required dependencies.
|
||||
If you want to be able to use the automatic login, run `pip install -r optional_requirements.txt`
|
||||
If you are on Arch you can run `sudo pacman --needed -S python-wheel python-setuptools python-pyqt5 python-qtawesome python-requests python-psutil`
|
||||
3. Run `python3 -m rare`
|
||||
|
||||
## Why Rare?
|
||||
|
||||
|
|
1
optional_requirements.txt
Normal file
1
optional_requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
pywebview[gtk]
|
|
@ -64,6 +64,9 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
|
|||
super(LaunchDialog, self).__init__(parent=parent)
|
||||
self.setupUi(self)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
||||
self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint)
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
|
||||
self.core = shared.core
|
||||
self.offline = shared.args.offline
|
||||
self.thread_pool = QThreadPool()
|
||||
|
|
|
@ -29,6 +29,7 @@ class LoginDialog(QDialog, Ui_LoginDialog):
|
|||
self.setupUi(self)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose, True)
|
||||
self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint)
|
||||
self.setWindowModality(Qt.WindowModal)
|
||||
|
||||
self.core = core
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from PyQt5.QtCore import pyqtSignal, QUrl
|
|||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QWidget, QApplication
|
||||
|
||||
from legendary.utils import webview_login
|
||||
from legendary.core import LegendaryCore
|
||||
from rare.ui.components.dialogs.login.browser_login import Ui_BrowserLogin
|
||||
from rare.utils.extra_widgets import IndicatorLineEdit
|
||||
|
@ -77,4 +78,18 @@ class BrowserLogin(QWidget, Ui_BrowserLogin):
|
|||
logger.warning(e)
|
||||
|
||||
def open_browser(self):
|
||||
QDesktopServices.openUrl(QUrl(self.login_url))
|
||||
if webview_login.webview_available is False:
|
||||
logger.warning("You don't have webengine installed, "
|
||||
"you will need to manually copy the SID.")
|
||||
QDesktopServices.openUrl(QUrl(self.login_url))
|
||||
else:
|
||||
if webview_login.do_webview_login(
|
||||
callback_sid=self.core.auth_sid,
|
||||
callback_code=self.core.auth_code):
|
||||
logger.info(
|
||||
"Successfully logged in as "
|
||||
f"{self.core.lgd.userdata['displayName']}"
|
||||
)
|
||||
self.success.emit()
|
||||
else:
|
||||
logger.warning("Failed to login through browser.")
|
||||
|
|
11
setup.py
11
setup.py
|
@ -1,5 +1,3 @@
|
|||
import os
|
||||
|
||||
import setuptools
|
||||
|
||||
from rare import __version__ as version
|
||||
|
@ -18,8 +16,12 @@ requirements = [
|
|||
'pywin32; platform_system == "Windows"'
|
||||
]
|
||||
|
||||
if os.name == "nt":
|
||||
requirements.append("pywin32")
|
||||
optional_reqs = dict(
|
||||
webview=[
|
||||
'pywebview[gtk]; platform_system == "Linux"',
|
||||
'pywebview[cef]; platform_system == "Windows"'
|
||||
]
|
||||
)
|
||||
|
||||
setuptools.setup(
|
||||
name="Rare",
|
||||
|
@ -45,4 +47,5 @@ setuptools.setup(
|
|||
python_requires=">=3.8",
|
||||
entry_points=dict(console_scripts=["rare=rare.__main__:main"]),
|
||||
install_requires=requirements,
|
||||
extras_require=optional_reqs
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue