added httpauth settings (without gui,, have to directly enter in config-file), closes #39
This commit is contained in:
parent
41f6cfeda2
commit
affdf4e37c
4 changed files with 55 additions and 2 deletions
|
|
@ -136,6 +136,10 @@ Page {
|
|||
var ttrss = rootWindow.getTTRSS();
|
||||
ttrss.clearState();
|
||||
ttrss.setLoginDetails(username.text, password.text, server.text);
|
||||
if (settings.httpauthusername != '' && settings.httpauthpassword != '') {
|
||||
ttrss.setHttpAuthInfo(settings.httpauthusername, settings.httpauthpassword);
|
||||
console.log('doing http basic auth with user ' + settings.httpauthusername)
|
||||
}
|
||||
ttrss.login(loginSuccessfull);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ var state={
|
|||
'url': null,
|
||||
'username': null,
|
||||
'password': null,
|
||||
'httpauth': { 'dobasicauth' : false },
|
||||
'token': null,
|
||||
'apilevel': 0,
|
||||
'numStatusUpdates': 0, //each time the state updates such that the app might want to redisplay we update this (get via getNumStatusUpdates)
|
||||
|
|
@ -139,10 +140,20 @@ function setLoginDetails(username, password, url) {
|
|||
trace(2, "api url is " + url);
|
||||
}
|
||||
|
||||
function setHttpAuthInfo(username, password) {
|
||||
state['httpauth']['username'] = username
|
||||
state['httpauth']['password'] = password
|
||||
state['httpauth']['dobasicauth'] = true
|
||||
}
|
||||
|
||||
function networkCall(params, callback) {
|
||||
var http = new XMLHttpRequest();
|
||||
//if you want http-auth, do http.open("POST", state['url'], true, username, passoword) instead
|
||||
http.open("POST", state['url'], true);
|
||||
|
||||
if (state['httpauth']['dobasicauth'])
|
||||
http.open("POST", state['url'], true, state['httpauth']['username'], state['httpauth']['password']);
|
||||
else
|
||||
http.open("POST", state['url'], true);
|
||||
|
||||
http.setRequestHeader('Content-type','application/json; charset=utf-8');
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
|
|
|
|||
19
settings.cpp
19
settings.cpp
|
|
@ -46,6 +46,22 @@ void Settings::setPassword(QString password) {
|
|||
}
|
||||
}
|
||||
|
||||
void Settings::setHttpauthUsername(QString username) {
|
||||
if (_httpauthuser != username) {
|
||||
_httpauthuser = username;
|
||||
m_settings->setValue("httpauthusername", _httpauthuser);
|
||||
emit httpauthUsernameChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setHttpauthPassword(QString password) {
|
||||
if (_httpauthpasswd != password) {
|
||||
_httpauthpasswd = password;
|
||||
m_settings->setValue("httpauthpassword", _httpauthpasswd);
|
||||
emit httpauthPasswordChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setAutologin(bool autologin) {
|
||||
if (_autologin != autologin) {
|
||||
_autologin = autologin;
|
||||
|
|
@ -92,6 +108,9 @@ Settings::Settings(QObject *parent) : QObject(parent), m_settings(new QSettings(
|
|||
_password = m_settings->value("password", "").toString();
|
||||
_autologin = m_settings->value("autologin", false).toBool();
|
||||
|
||||
_httpauthuser = m_settings->value("httpauthusername", "").toString();
|
||||
_httpauthpasswd = m_settings->value("httpauthpassword", "").toString();
|
||||
|
||||
_whiteTheme = m_settings->value("whiteTheme", true).toBool();
|
||||
_feeditemsOrder = m_settings->value("feeditemsOrder", 0).toInt();
|
||||
_displayIcons = m_settings->value("displayIcons", true).toBool();
|
||||
|
|
|
|||
19
settings.hh
19
settings.hh
|
|
@ -16,6 +16,9 @@ class Settings : public QObject
|
|||
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
|
||||
Q_PROPERTY(bool autologin READ hasAutologin WRITE setAutologin NOTIFY autologinChanged)
|
||||
|
||||
Q_PROPERTY(QString httpauthusername READ httpauthUsername WRITE setHttpauthUsername NOTIFY httpauthUsernameChanged)
|
||||
Q_PROPERTY(QString httpauthpassword READ httpauthPassword WRITE setHttpauthPassword NOTIFY httpauthPasswordChanged)
|
||||
|
||||
Q_PROPERTY(bool whiteTheme READ isWhiteTheme WRITE setWhiteTheme NOTIFY whiteThemeChanged)
|
||||
Q_PROPERTY(int feeditemsOrder READ feeditemsOrder WRITE setFeeditemsOrder NOTIFY feeditemsOrderChanged)
|
||||
Q_PROPERTY(bool displayIcons READ displayIcons WRITE setDisplayIcons NOTIFY displayIconsChanged)
|
||||
|
|
@ -47,6 +50,16 @@ public:
|
|||
}
|
||||
void setAutologin(bool autologin);
|
||||
|
||||
QString httpauthUsername() const {
|
||||
return this->_httpauthuser;
|
||||
}
|
||||
void setHttpauthUsername(QString username);
|
||||
|
||||
QString httpauthPassword() const {
|
||||
return this->_httpauthpasswd;
|
||||
}
|
||||
void setHttpauthPassword(QString password);
|
||||
|
||||
bool isWhiteTheme() const {
|
||||
return this->_whiteTheme;
|
||||
}
|
||||
|
|
@ -73,6 +86,9 @@ signals:
|
|||
void passwordChanged();
|
||||
void autologinChanged();
|
||||
|
||||
void httpauthUsernameChanged();
|
||||
void httpauthPasswordChanged();
|
||||
|
||||
void whiteThemeChanged();
|
||||
void feeditemsOrderChanged();
|
||||
void displayIconsChanged();
|
||||
|
|
@ -91,6 +107,9 @@ private:
|
|||
QString _password;
|
||||
bool _autologin;
|
||||
|
||||
QString _httpauthuser;
|
||||
QString _httpauthpasswd;
|
||||
|
||||
bool _whiteTheme;
|
||||
int _feeditemsOrder;
|
||||
bool _displayIcons;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue