mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Added support for more authentication methods for the default calendar module
HTTP Basic, Digest and OAuth2/Bearer authentications are now supported by the calendar module
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
var ical = require("./vendor/ical.js");
|
||||
var moment = require("moment");
|
||||
|
||||
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, user, pass) {
|
||||
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, auth) {
|
||||
var self = this;
|
||||
|
||||
var reloadTimer = null;
|
||||
@@ -32,11 +32,23 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
}
|
||||
};
|
||||
|
||||
if (user && pass) {
|
||||
opts.auth = {
|
||||
user: user,
|
||||
pass: pass,
|
||||
sendImmediately: true
|
||||
if (auth) {
|
||||
if(auth.method === 'bearer'){
|
||||
opts.auth = {
|
||||
bearer: auth.pass
|
||||
}
|
||||
|
||||
}else{
|
||||
opts.auth = {
|
||||
user: auth.user,
|
||||
pass: auth.pass
|
||||
};
|
||||
|
||||
if(auth.method === 'digest'){
|
||||
opts.auth.sendImmediately = false;
|
||||
}else{
|
||||
opts.auth.sendImmediately = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +59,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
return;
|
||||
}
|
||||
|
||||
//console.log(data);
|
||||
// console.log(data);
|
||||
newEvents = [];
|
||||
|
||||
var limitFunction = function(date, i) {return i < maximumEntries;};
|
||||
|
Reference in New Issue
Block a user