mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-03 06:15:59 +00:00
Merge pull request #433 from icewind1991/webcal-auth
add support for http basic auth for calendars
This commit is contained in:
commit
3c936c6957
@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Added ability to remove tags from the beginning or end of newsfeed items in 'newsfeed.js'.
|
- Added ability to remove tags from the beginning or end of newsfeed items in 'newsfeed.js'.
|
||||||
- Added ability to define "the day after tomorrow" for calendar events (Definition for German and Dutch already included).
|
- Added ability to define "the day after tomorrow" for calendar events (Definition for German and Dutch already included).
|
||||||
- Added CII Badge (we are compliant with the CII Best Practices)
|
- Added CII Badge (we are compliant with the CII Best Practices)
|
||||||
|
- Add support for doing http basic auth when loading calendars
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix typo in installer.
|
- Fix typo in installer.
|
||||||
|
@ -183,5 +183,13 @@ config: {
|
|||||||
<code>'Birthday'</code>
|
<code>'Birthday'</code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code> user </code></td>
|
||||||
|
<td>The username for HTTP Basic authentication.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code> pass </code></td>
|
||||||
|
<td>The password for HTTP Basic authentication.</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -64,7 +64,7 @@ Module.register("calendar",{
|
|||||||
for (var c in this.config.calendars) {
|
for (var c in this.config.calendars) {
|
||||||
var calendar = this.config.calendars[c];
|
var calendar = this.config.calendars[c];
|
||||||
calendar.url = calendar.url.replace("webcal://", "http://");
|
calendar.url = calendar.url.replace("webcal://", "http://");
|
||||||
this.addCalendar(calendar.url);
|
this.addCalendar(calendar.url, calendar.user, calendar.pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.calendarData = {};
|
this.calendarData = {};
|
||||||
@ -285,12 +285,14 @@ Module.register("calendar",{
|
|||||||
*
|
*
|
||||||
* argument url sting - Url to add.
|
* argument url sting - Url to add.
|
||||||
*/
|
*/
|
||||||
addCalendar: function(url) {
|
addCalendar: function(url, user, pass) {
|
||||||
this.sendSocketNotification("ADD_CALENDAR", {
|
this.sendSocketNotification("ADD_CALENDAR", {
|
||||||
url: url,
|
url: url,
|
||||||
maximumEntries: this.config.maximumEntries,
|
maximumEntries: this.config.maximumEntries,
|
||||||
maximumNumberOfDays: this.config.maximumNumberOfDays,
|
maximumNumberOfDays: this.config.maximumNumberOfDays,
|
||||||
fetchInterval: this.config.fetchInterval
|
fetchInterval: this.config.fetchInterval,
|
||||||
|
user: user,
|
||||||
|
pass: pass
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
var ical = require("./vendor/ical.js");
|
var ical = require("./vendor/ical.js");
|
||||||
var moment = require("moment");
|
var moment = require("moment");
|
||||||
|
|
||||||
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays) {
|
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, user, pass) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var reloadTimer = null;
|
var reloadTimer = null;
|
||||||
@ -29,7 +29,16 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (Node.js 6.0.0) MagicMirror/v2 (https://github.com/MichMich/MagicMirror/)'
|
'User-Agent': 'Mozilla/5.0 (Node.js 6.0.0) MagicMirror/v2 (https://github.com/MichMich/MagicMirror/)'
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (user && pass) {
|
||||||
|
opts.auth = {
|
||||||
|
user: user,
|
||||||
|
pass: pass,
|
||||||
|
sendImmediately: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ical.fromURL(url, opts, function(err, data) {
|
ical.fromURL(url, opts, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fetchFailedCallback(self, err);
|
fetchFailedCallback(self, err);
|
||||||
|
@ -25,7 +25,7 @@ module.exports = NodeHelper.create({
|
|||||||
socketNotificationReceived: function(notification, payload) {
|
socketNotificationReceived: function(notification, payload) {
|
||||||
if (notification === "ADD_CALENDAR") {
|
if (notification === "ADD_CALENDAR") {
|
||||||
//console.log('ADD_CALENDAR: ');
|
//console.log('ADD_CALENDAR: ');
|
||||||
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays);
|
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays, payload.user, payload.pass);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ module.exports = NodeHelper.create({
|
|||||||
* attribute reloadInterval number - Reload interval in milliseconds.
|
* attribute reloadInterval number - Reload interval in milliseconds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays) {
|
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays, user, pass) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!validUrl.isUri(url)) {
|
if (!validUrl.isUri(url)) {
|
||||||
@ -48,7 +48,7 @@ module.exports = NodeHelper.create({
|
|||||||
var fetcher;
|
var fetcher;
|
||||||
if (typeof self.fetchers[url] === "undefined") {
|
if (typeof self.fetchers[url] === "undefined") {
|
||||||
console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
||||||
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays);
|
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, user, pass);
|
||||||
|
|
||||||
fetcher.onReceive(function(fetcher) {
|
fetcher.onReceive(function(fetcher) {
|
||||||
//console.log('Broadcast events.');
|
//console.log('Broadcast events.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user