def POST(self): """Overrides `account_login` and infogami.login to prevent users from logging in with Open Library username and password if the payload is json. Instead, if login attempted w/ json credentials, requires Archive.org s3 keys. """ from openlibrary.plugins.openlibrary.code import BadRequest d = simplejson.loads(web.data()) access = d.get('access', None) secret = d.get('secret', None) test = d.get('test', False) # Try S3 authentication first, fallback to infogami user, pass if access and secret: audit = audit_accounts(None, None, require_link=True, s3_access_key=access, s3_secret_key=secret, test=test) error = audit.get('error') if error: raise olib.code.BadRequest(error) web.setcookie(config.login_cookie_name, web.ctx.conn.get_auth_token()) # Fallback to infogami user/pass else: from infogami.plugins.api.code import login as infogami_login infogami_login().POST()
def POST(self): """Overrides `account_login` and infogami.login to prevent users from logging in with Open Library username and password if the payload is json. Instead, if login attempted w/ json credentials, requires Archive.org s3 keys. """ from openlibrary.plugins.openlibrary.code import BadRequest d = simplejson.loads(web.data()) access = d.get('access', None) secret = d.get('secret', None) test = d.get('test', False) # Try S3 authentication first, fallback to infogami user, pass if access and secret: audit = audit_accounts(None, None, require_link=True, s3_access_key=access, s3_secret_key=secret, test=test) error = audit.get('error') if error: raise olib.code.BadRequest(error) web.setcookie(config.login_cookie_name, web.ctx.conn.get_auth_token()) # Fallback to infogami user/pass else: from infogami.plugins.api.code import login as infogami_login infogami_login().POST()