URL calendars for anonymous users

pull/1/head
yflory 4 years ago
parent 8701443f0f
commit f2b63639c6

@ -375,7 +375,7 @@ define([
}
});
}
if (data.teams.indexOf(1) === -1 || teamId === 0) {
if (APP.loggedIn && (data.teams.indexOf(1) === -1 || teamId === 0)) {
options.push({
tag: 'a',
attributes: {
@ -387,10 +387,10 @@ define([
importCalendar({
id: id,
teamId: teamId
}, function (obj) {
if (obj && obj.error) {
console.error(obj.error);
return void UI.warn(obj.error);
}, function (err) {
if (err) {
console.error(err);
return void UI.warn(Messages.error);
}
});
return true;
@ -677,14 +677,16 @@ define([
importCalendar({
id: tempCalendars[0],
teamId: 0
}, function (obj) {
if (obj && obj.error) {
console.error(obj.error);
return void UI.warn(obj.error);
}, function (err) {
if (err) {
console.error(err);
return void UI.warn(Messages.error);
}
});
});
if (APP.loggedIn) {
APP.$calendars.append(h('div.cp-calendar-entry.cp-ghost', importTemp));
}
return;
}
var myCalendars = filter(1);
@ -1111,6 +1113,8 @@ define([
var privateData = metadataMgr.getPrivateData();
var user = metadataMgr.getUserData();
APP.loggedIn = common.isLoggedIn();
common.setTabTitle(Messages.calendar);
// Fix flatpickr selection
@ -1248,6 +1252,11 @@ define([
var store = window.cryptpadStore;
APP.module.execCommand('SUBSCRIBE', null, function (obj) {
if (obj.empty && !privateData.calendarHash) {
if (!privateData.loggedIn) {
return void UI.errorLoadingScreen(Messages.mustLogin, false, function () {
common.setLoginRedirect('login');
});
}
// No calendar yet, create one
newCalendar({
teamId: 1,

@ -20,7 +20,7 @@ define(function() {
* users and these users will be redirected to the login page if they still try to access
* the app
*/
config.registeredOnlyTypes = ['file', 'contacts', 'notifications', 'support', 'calendar'];
config.registeredOnlyTypes = ['file', 'contacts', 'notifications', 'support'];
/* CryptPad is available is multiple languages, but only English and French are maintained
* by the developers. The other languages may be outdated, and any missing string for a langauge

@ -114,8 +114,8 @@ define([
}
}
// XXX add a limit to make sure we don't go too far in the past? ==> 1 week
var missed = useLastVisit && ev.start > last && ev.end <= now;
var oneWeekAgo = now - (7 * 24 * 3600 * 1000);
var missed = useLastVisit && ev.start > last && ev.end <= now && ev.end > oneWeekAgo;
if (ev.end <= now && !missed) {
// No reminder for past events
delete reminders[uid];
@ -543,6 +543,8 @@ define([
var hash = Hash.getEditHashFromKeys(secret);
var roHash = Hash.getViewHashFromKeys(secret);
if (!ctx.loggedIn) { hash = undefined; }
var cal = {
href: hash && Hash.hashToHref(hash, 'calendar'),
roHref: roHash && Hash.hashToHref(roHash, 'calendar'),
@ -846,8 +848,9 @@ define([
Calendar.init = function (cfg, waitFor, emit) {
var calendar = {};
var store = cfg.store;
if (!store.loggedIn || !store.proxy.edPublic) { return; } // XXX logged in only? we should al least allow read-only for URL calendars
//if (!store.loggedIn || !store.proxy.edPublic) { return; } // XXX logged in only? we should al least allow read-only for URL calendars
var ctx = {
loggedIn: store.loggedIn && store.proxy.edPublic,
store: store,
Store: cfg.Store,
pinPads: cfg.pinPads,
@ -918,17 +921,21 @@ define([
}
if (cmd === 'IMPORT') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void importCalendar(ctx, data, clientId, cb);
}
if (cmd === 'IMPORT_ICS') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void importICSCalendar(ctx, data, clientId, cb);
}
if (cmd === 'ADD') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void addCalendar(ctx, data, clientId, cb);
}
if (cmd === 'CREATE') {
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
if (data.initialCalendar) {
return void ctx.Store.onReadyEvt.reg(function () {
createCalendar(ctx, data, clientId, cb);
@ -939,22 +946,27 @@ define([
}
if (cmd === 'UPDATE') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void updateCalendar(ctx, data, clientId, cb);
}
if (cmd === 'DELETE') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void deleteCalendar(ctx, data, clientId, cb);
}
if (cmd === 'CREATE_EVENT') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void createEvent(ctx, data, clientId, cb);
}
if (cmd === 'UPDATE_EVENT') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void updateEvent(ctx, data, clientId, cb);
}
if (cmd === 'DELETE_EVENT') {
if (ctx.store.offline) { return void cb({error: 'OFFLINE'}); }
if (!ctx.loggedIn) { return void cb({error: 'NOT_LOGGED_IN'}); }
return void deleteEvent(ctx, data, clientId, cb);
}
};

Loading…
Cancel
Save