From 8f5c662bc62cafb84dce6de1d61dd438fb766838 Mon Sep 17 00:00:00 2001 From: Molly Smith Date: Tue, 22 Oct 2024 16:27:43 -0600 Subject: [PATCH] Removed sign-in link from top of page --- .../imports/startup/api/matsMethods.js | 113 ------------------ .../imports/startup/both/mats-collections.js | 4 - .../imports/startup/client/init.js | 1 - .../imports/startup/server/data_util.js | 23 ---- .../mats-common/templates/topnav/top_nav.html | 3 - 5 files changed, 144 deletions(-) diff --git a/meteor_packages/mats-common/imports/startup/api/matsMethods.js b/meteor_packages/mats-common/imports/startup/api/matsMethods.js index e8d53367b..4bcaa835d 100644 --- a/meteor_packages/mats-common/imports/startup/api/matsMethods.js +++ b/meteor_packages/mats-common/imports/startup/api/matsMethods.js @@ -2091,115 +2091,6 @@ const dropScorecardInstance = new ValidatedMethod({ }, }); -// administration tools -const emailImage = new ValidatedMethod({ - name: "matsMethods.emailImage", - validate: new SimpleSchema({ - imageStr: { - type: String, - }, - toAddress: { - type: String, - }, - subject: { - type: String, - }, - }).validator(), - run(params) { - const { imageStr } = params; - const { toAddress } = params; - const { subject } = params; - if (!Meteor.userId()) { - throw new Meteor.Error(401, "not-logged-in"); - } - const fromAddress = Meteor.user().services.google.email; - // these come from google - see - // http://masashi-k.blogspot.fr/2013/06/sending-mail-with-gmail-using-xoauth2.html - // http://stackoverflow.com/questions/24098461/nodemailer-gmail-what-exactly-is-a-refresh-token-and-how-do-i-get-one/24123550 - - // the gmail account for the credentials is mats.mail.daemon@gmail.com - pwd mats2015! - // var clientId = "339389735380-382sf11aicmgdgn7e72p4end5gnm9sad.apps.googleusercontent.com"; - // var clientSecret = "7CfNN-tRl5QAL595JTW2TkRl"; - // var refresh_token = "1/PDql7FR01N2gmq5NiTfnrT-OlCYC3U67KJYYDNPeGnA"; - const credentials = matsCollections.Credentials.findOne( - { - name: "oauth_google", - }, - { - clientId: 1, - clientSecret: 1, - refresh_token: 1, - } - ); - const { clientId } = credentials; - const { clientSecret } = credentials; - const refreshToken = credentials.refresh_token; - - let smtpTransporter; - try { - const Nodemailer = require("nodemailer"); - smtpTransporter = Nodemailer.createTransport("SMTP", { - service: "Gmail", - auth: { - XOAuth2: { - user: "mats.gsl@noaa.gov", - clientId, - clientSecret, - refreshToken, - }, - }, - }); - } catch (e) { - throw new Meteor.Error(401, `Transport error ${e.message()}`); - } - try { - const mailOptions = { - sender: fromAddress, - replyTo: fromAddress, - from: fromAddress, - to: toAddress, - subject, - attachments: [ - { - filename: "graph.png", - contents: Buffer.from(imageStr.split("base64,")[1], "base64"), - }, - ], - }; - - smtpTransporter.sendMail(mailOptions, function (error, response) { - if (error) { - console.log( - `smtpTransporter error ${error} from:${fromAddress} to:${toAddress}` - ); - } else { - console.log(`${response} from:${fromAddress} to:${toAddress}`); - } - smtpTransporter.close(); - }); - } catch (e) { - throw new Meteor.Error(401, `Send error ${e.message()}`); - } - return false; - }, -}); - -// administation tool -const getAuthorizations = new ValidatedMethod({ - name: "matsMethods.getAuthorizations", - validate: new SimpleSchema({}).validator(), - run() { - let roles = []; - if (Meteor.isServer) { - const userEmail = Meteor.user().services.google.email.toLowerCase(); - roles = matsCollections.Authorization.findOne({ - email: userEmail, - }).roles; - } - return roles; - }, -}); - // administration tool const getRunEnvironment = new ValidatedMethod({ @@ -3016,8 +2907,6 @@ const resetApp = async function (appRef) { matsDataUtils.doRoles(); matsCollections.Authorization.remove({}); matsDataUtils.doAuthorization(); - matsCollections.Credentials.remove({}); - matsDataUtils.doCredentials(); matsCollections.PlotGraphFunctions.remove({}); matsCollections.ColorScheme.remove({}); matsDataUtils.doColorScheme(); @@ -3959,8 +3848,6 @@ export default matsMethods = { applySettingsData, deleteSettings, dropScorecardInstance, - emailImage, - getAuthorizations, getRunEnvironment, getDefaultGroupList, getGraphData, diff --git a/meteor_packages/mats-common/imports/startup/both/mats-collections.js b/meteor_packages/mats-common/imports/startup/both/mats-collections.js index 7abdea832..9d52e93d4 100644 --- a/meteor_packages/mats-common/imports/startup/both/mats-collections.js +++ b/meteor_packages/mats-common/imports/startup/both/mats-collections.js @@ -46,8 +46,6 @@ const Roles = new Mongo.Collection("Roles"); const SavedRoles = new Mongo.Collection("SavedRoles"); const Databases = new Mongo.Collection("Databases"); const SavedDatabases = new Mongo.Collection("SavedDatabases"); -const Credentials = new Mongo.Collection("Credentials"); -const SavedCredentials = new Mongo.Collection("SavedCredentials"); const SiteMap = new Mongo.Collection("SiteMap"); const StationMap = new Mongo.Collection("StationMap"); const Scorecard = new Mongo.Collection("Scorecard"); @@ -81,8 +79,6 @@ const explicitCollections = { SavedRoles, Databases, SavedDatabases, - Credentials, - SavedCredentials, SiteMap, StationMap, Scorecard, diff --git a/meteor_packages/mats-common/imports/startup/client/init.js b/meteor_packages/mats-common/imports/startup/client/init.js index f9d432ca4..c48d0c613 100644 --- a/meteor_packages/mats-common/imports/startup/client/init.js +++ b/meteor_packages/mats-common/imports/startup/client/init.js @@ -34,7 +34,6 @@ if (Meteor.isClient) { Meteor.subscribe("SentAddresses"); Meteor.subscribe("Roles"); Meteor.subscribe("Authorization"); - Meteor.subscribe("Credentials"); Meteor.subscribe("Databases"); Meteor.subscribe("CurveTextPatterns"); Meteor.subscribe("ScatterAxisTextPattern"); diff --git a/meteor_packages/mats-common/imports/startup/server/data_util.js b/meteor_packages/mats-common/imports/startup/server/data_util.js index 12eda797a..a230f8a11 100644 --- a/meteor_packages/mats-common/imports/startup/server/data_util.js +++ b/meteor_packages/mats-common/imports/startup/server/data_util.js @@ -290,28 +290,6 @@ const doColorScheme = function () { } }; -// utility for google login capabilities in MATS -- broken for esrl.noaa.gov/gsd/mats? -const doCredentials = function () { - // the gmail account for the credentials is mats.mail.daemon@gmail.com - pwd mats2015! - if ( - matsCollections.Settings.findOne({}) === undefined || - matsCollections.Settings.findOne({}).resetFromCode === undefined || - matsCollections.Settings.findOne({}).resetFromCode === true - ) { - matsCollections.Credentials.remove({}); - } - if (matsCollections.Credentials.find().count() === 0) { - matsCollections.Credentials.insert({ - name: "oauth_google", - clientId: - "499180266722-aai2tddo8s9edv4km1pst88vebpf9hec.apps.googleusercontent.com", - clientSecret: "xdU0sc7SbdOOEzSyID_PTIRE", - refresh_token: - "1/3bhWyvCMMfwwDdd4F3ftlJs3-vksgg7G8POtiOBwYnhIgOrJDtdun6zK6XiATCKT", - }); - } -}; - // another utility to assist at logging into MATS const doRoles = function () { if ( @@ -2177,7 +2155,6 @@ export default matsDataUtils = { secsConvert, doAuthorization, doColorScheme, - doCredentials, doRoles, doSettings, callMetadataAPI, diff --git a/meteor_packages/mats-common/templates/topnav/top_nav.html b/meteor_packages/mats-common/templates/topnav/top_nav.html index 82f769416..d678b48a6 100644 --- a/meteor_packages/mats-common/templates/topnav/top_nav.html +++ b/meteor_packages/mats-common/templates/topnav/top_nav.html @@ -158,9 +158,6 @@ >Contact Us -
  • - {{> loginButtons align="right"}} -