Merge branch 'autologin_config' of https://github.com/codesoap/rtv into codesoap-autologin_config

This commit is contained in:
Michael Lazar
2018-10-01 01:16:11 -04:00
3 changed files with 9 additions and 2 deletions

View File

@@ -202,7 +202,7 @@ def main():
# Authorize on launch if the refresh token is present # Authorize on launch if the refresh token is present
oauth = OAuthHelper(reddit, term, config) oauth = OAuthHelper(reddit, term, config)
if config.refresh_token: if config['autologin'] and config.refresh_token:
oauth.authorize() oauth.authorize()
page = None page = None

View File

@@ -64,6 +64,9 @@ def build_parser():
parser.add_argument( parser.add_argument(
'--non-persistent', dest='persistent', action='store_const', const=False, '--non-persistent', dest='persistent', action='store_const', const=False,
help='Forget the authenticated user when the program exits') help='Forget the authenticated user when the program exits')
parser.add_argument(
'--no-autologin', dest='autologin', action='store_const', const=False,
help='Do not authenticate automatically on startup')
parser.add_argument( parser.add_argument(
'--clear-auth', dest='clear_auth', action='store_const', const=True, '--clear-auth', dest='clear_auth', action='store_const', const=True,
help='Remove any saved user data before launching') help='Remove any saved user data before launching')
@@ -258,8 +261,9 @@ class Config(object):
params = { params = {
'ascii': partial(config.getboolean, 'rtv'), 'ascii': partial(config.getboolean, 'rtv'),
'monochrome': partial(config.getboolean, 'rtv'), 'monochrome': partial(config.getboolean, 'rtv'),
'clear_auth': partial(config.getboolean, 'rtv'),
'persistent': partial(config.getboolean, 'rtv'), 'persistent': partial(config.getboolean, 'rtv'),
'autologin': partial(config.getboolean, 'rtv'),
'clear_auth': partial(config.getboolean, 'rtv'),
'enable_media': partial(config.getboolean, 'rtv'), 'enable_media': partial(config.getboolean, 'rtv'),
'history_size': partial(config.getint, 'rtv'), 'history_size': partial(config.getint, 'rtv'),
'oauth_redirect_port': partial(config.getint, 'rtv'), 'oauth_redirect_port': partial(config.getint, 'rtv'),

View File

@@ -31,6 +31,9 @@ subreddit = front
; Allow rtv to store reddit authentication credentials between sessions. ; Allow rtv to store reddit authentication credentials between sessions.
persistent = True persistent = True
; Automatically log in on startup, if credentials are available.
autologin = True
; Clear any stored credentials when the program starts. ; Clear any stored credentials when the program starts.
clear_auth = False clear_auth = False