Commit 460663bb authored by Curtis Adam's avatar Curtis Adam

Move the login settings over to the new system

parent 34649b4d
......@@ -76,4 +76,25 @@ export let ServerStyle = class ServerStyle {
return "url('" + backgroundSring + "')";
}
}
static isLoginEnabled (loginType) {
let settings = this.getConfig();
switch (loginType) {
case "cas":
return settings.login.cas;
case "guest":
return settings.login.guest;
case "pro":
return settings.login.pro;
case "legacy":
return settings.login.legacyMode.enabled;
case "google":
return settings.login.legacyMode.google;
case "twitter":
return settings.login.legacyMode.twitter;
case "facebook":
return settings.login.legacyMode.facebook;
case "backdoor":
return Meteor.settings.public.backdoorEnabled;
}
}
};
let defaultSettings = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": false,
"pro": false
},
"welcome": {
"title": {
"first": "informatik",
......@@ -10,6 +21,17 @@ let defaultSettings = {
};
let debug = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": true,
"pro": true
},
"welcome": {
"title": {
"first": "debug",
......@@ -21,6 +43,17 @@ let debug = {
};
let informatik = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": true,
"pro": false
},
"welcome": {
"title": {
"first": "informatik",
......@@ -32,6 +65,17 @@ let informatik = {
};
let linux = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": true,
"pro": false
},
"welcome": {
"title": {
"first": "Linux",
......@@ -43,6 +87,17 @@ let linux = {
};
let review = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": false,
"guest": false,
"pro": false
},
"welcome": {
"title": {
"first": "review",
......@@ -54,6 +109,17 @@ let review = {
};
let staging = {
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": true,
"pro": true
},
"welcome": {
"title": {
"first": "staging",
......
......@@ -281,7 +281,7 @@ Template.registerHelper("learningActiveAndEditor", function () {
});
Template.registerHelper("isProLoginActive", function () {
return (Meteor.settings.public.login.legacyMode.enabled || Meteor.settings.public.login.pro);
return (ServerStyle.isLoginEnabled("legacy") || ServerStyle.isLoginEnabled("pro"));
});
Template.registerHelper("isEditor", function () {
......
import {ServerStyle} from "../../api/styles";
ServiceConfiguration.configurations.remove({
service: 'facebook'
});
......@@ -31,7 +33,7 @@ ServiceConfiguration.configurations.insert({
Meteor.users.after.insert(function (userId, doc) {
// Setup roles for backdoor login, required for acceptance tests
if (Meteor.settings.public.login.backdoor) {
if (ServerStyle.isLoginEnabled("backdoor")) {
let backdoorRoles = ['firstLogin'];
let username = "";
let firstName = "";
......
......@@ -14,6 +14,7 @@ import {CardVisuals} from "../../api/cardVisuals";
import {NavigatorCheck} from "../../api/navigatorCheck";
import {AdminSettings} from "../../api/adminSettings";
import {WordcloudCanvas} from "../../api/wordcloudCanvas";
import {ServerStyle} from "../../api/styles.js";
Meteor.subscribe("pomodoroLandingPage");
Meteor.subscribe("userData");
......@@ -88,7 +89,7 @@ Template.welcome.events({
// Backdoor for login in acceptance tests
'click #BackdoorLogin': function () {
if (Meteor.settings.public.login.backdoor) {
if (Meteor.settings.public.backdoorEnabled) {
Meteor.insecureUserLogin($("#TestingBackdoorUsername").val(), function (err, result) {
if (result) {
setActiveLanguage();
......@@ -109,32 +110,32 @@ Template.welcome.events({
Template.welcome.helpers({
getLoginButtons: function () {
let loginButtons = "<div id='loginButtonRow'>";
if (Meteor.settings.public.login.legacyMode.enabled) {
if (Meteor.settings.public.login.cas) {
if (ServerStyle.isLoginEnabled("legacy")) {
if (ServerStyle.isLoginEnabled("cas")) {
loginButtons += '<a id="cas" href=""><div class="' + getLoginClass() + '"></div></a>';
}
if (Meteor.settings.public.login.legacyMode.facebook) {
if (ServerStyle.isLoginEnabled("facebook")) {
loginButtons += '<a id="facebook" href=""><div class="' + getLoginClass() + '"></div></a>';
}
if (Meteor.settings.public.login.legacyMode.twitter) {
if (ServerStyle.isLoginEnabled("twitter")) {
loginButtons += '<a id="twitter" href=""><div class="' + getLoginClass() + '"></div></a>';
}
if (Meteor.settings.public.login.legacyMode.google) {
if (ServerStyle.isLoginEnabled("google")) {
loginButtons += '<a id="google" href=""><div class="' + getLoginClass() + '"></div></a>';
}
} else {
if (Meteor.settings.public.login.cas) {
if (ServerStyle.isLoginEnabled("cas")) {
loginButtons += '<button id="cas" class="btn btn-large btn-raised btn-block" title="' + TAPi18n.__("landingPage.login.tooltip.cas") + '"><span class="flex-content"><i class="fa fa-university"></i>&nbsp;' + TAPi18n.__("landingPage.login.cas") + '</span></button>';
}
if (Meteor.settings.public.login.guest) {
if (ServerStyle.isLoginEnabled("guest")) {
loginButtons += '<button id="guest" class="btn btn-large btn-raised btn-block" data-toggle="modal" data-target="#underDevelopmentModal" title="' + TAPi18n.__("landingPage.login.tooltip.guest") + '"><span class="flex-content"><i class="fa fa-user"></i>&nbsp;' + TAPi18n.__("landingPage.login.guest") + '</span></button>';
}
if (Meteor.settings.public.login.pro) {
if (ServerStyle.isLoginEnabled("pro")) {
loginButtons += '<button id="pro" class="btn btn-large btn-raised btn-block" data-toggle="modal" data-target="#underDevelopmentModal" title="' + TAPi18n.__("landingPage.login.tooltip.pro") + '"><span class="flex-content"><i class="fa fa-paypal"></i>&nbsp;' + TAPi18n.__("landingPage.login.pro") + '</span></button>';
}
}
// Backdoor for login in acceptance tests
if (Meteor.settings.public.login.backdoor) {
if (ServerStyle.isLoginEnabled("backdoor")) {
let title = TAPi18n.__("backdoor.title");
let superAdmin = TAPi18n.__("backdoor.superAdmin");
let admin = TAPi18n.__("backdoor.admin");
......@@ -144,13 +145,13 @@ Template.welcome.helpers({
let standard = TAPi18n.__("backdoor.standard");
let blocked = TAPi18n.__("backdoor.blocked");
let firstLogin = TAPi18n.__("backdoor.firstLogin");
if (Meteor.settings.public.login.legacyMode.enabled) {
if (ServerStyle.isLoginEnabled("legacy")) {
loginButtons += '<a id="BackdoorLogin" href=""><div class="' + getLoginClass() + '"></div></a>';
} else {
loginButtons += '<button id="BackdoorLogin" class="btn btn-large btn-raised btn-block" title="' + TAPi18n.__("landingPage.login.tooltip.backdoor") + '"><span class="flex-content"><i class="fa fa-key"></i>&nbsp;' + TAPi18n.__("landingPage.login.backdoor") + '</span></button>';
}
loginButtons += '<div class="btn-group backdoorLogin">';
if (Meteor.settings.public.login.legacyMode.enabled) {
if (ServerStyle.isLoginEnabled("legacy")) {
loginButtons += '<label id="backdoor-label">' + title + '</label><br>';
}
loginButtons += '<select class="btn btn-secondary btn-raised" id="TestingBackdoorUsername" aria-labelledby="backdoor-label">' +
......
......@@ -2,24 +2,13 @@
"public": {
"rooturl": "http://localhost:3000",
"dynamicSettings": "default",
"backdoorEnabled": false,
"cas": {
"loginUrl": "https://cas.thm.de/cas/login",
"serviceParam": "service",
"popupWidth": 810,
"popupHeight": 610
},
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": false,
"pro": false,
"backdoor": false
},
"leitner": {
"dayIntervalHour": 1
},
......
......@@ -2,24 +2,13 @@
"public": {
"rooturl": "http://localhost:3000",
"dynamicSettings": "debug",
"backdoorEnabled": true,
"cas": {
"loginUrl": "https://cas.thm.de/cas/login",
"serviceParam": "service",
"popupWidth": 810,
"popupHeight": 610
},
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": true,
"guest": true,
"pro": true,
"backdoor": true
},
"leitner": {
"dayIntervalHour": 1
},
......
......@@ -2,24 +2,13 @@
"public": {
"rooturl": "http://localhost:<branch-port>",
"dynamicSettings": "review",
"backdoorEnabled": true,
"cas": {
"loginUrl": "https://cas.thm.de/cas/login",
"serviceParam": "service",
"popupWidth": 810,
"popupHeight": 610
},
"login": {
"legacyMode": {
"enabled": false,
"facebook": true,
"twitter": true,
"google": true
},
"cas": false,
"guest": false,
"pro": false,
"backdoor": true
},
"leitner": {
"dayIntervalHour": 1
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment