-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed sign-in link from top of page
- Loading branch information
1 parent
7156927
commit 8f5c662
Showing
5 changed files
with
0 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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({ | ||
|
@@ -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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ( | ||
|
@@ -2177,7 +2155,6 @@ export default matsDataUtils = { | |
secsConvert, | ||
doAuthorization, | ||
doColorScheme, | ||
doCredentials, | ||
doRoles, | ||
doSettings, | ||
callMetadataAPI, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters