Skip to content

Commit

Permalink
Removed sign-in link from top of page
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Oct 22, 2024
1 parent 7156927 commit 8f5c662
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 144 deletions.
113 changes: 0 additions & 113 deletions meteor_packages/mats-common/imports/startup/api/matsMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] - 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: "[email protected]",
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({
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -3959,8 +3848,6 @@ export default matsMethods = {
applySettingsData,
deleteSettings,
dropScorecardInstance,
emailImage,
getAuthorizations,
getRunEnvironment,
getDefaultGroupList,
getGraphData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -81,8 +79,6 @@ const explicitCollections = {
SavedRoles,
Databases,
SavedDatabases,
Credentials,
SavedCredentials,
SiteMap,
StationMap,
Scorecard,
Expand Down
1 change: 0 additions & 1 deletion meteor_packages/mats-common/imports/startup/client/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
23 changes: 0 additions & 23 deletions meteor_packages/mats-common/imports/startup/server/data_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] - 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 (
Expand Down Expand Up @@ -2177,7 +2155,6 @@ export default matsDataUtils = {
secsConvert,
doAuthorization,
doColorScheme,
doCredentials,
doRoles,
doSettings,
callMetadataAPI,
Expand Down
3 changes: 0 additions & 3 deletions meteor_packages/mats-common/templates/topnav/top_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@
><span style="color: white; font-size: medium">Contact Us</span></a
>
</li>
<li style="margin-top: 1.45em; margin-left: 0.95em">
{{> loginButtons align="right"}}
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
Expand Down

0 comments on commit 8f5c662

Please sign in to comment.