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
((d, w) => { | |
// select the static HTML element that all this DOM manipulation will be contained to | |
let widget = d.getElementById("medium-widget"); | |
const mainImgObserver = new MutationObserver(() => { | |
// if these elements have been rendered in the DOM | |
if (widget.getElementsByClassName("medium-widget-article__image").length > 0) { | |
// get the <a> link elements from the DOM, then map to get the child <img> elements | |
let imgElements = Array.from(widget.getElementsByClassName("medium-widget-article__image")) | |
.map((a) => a.firstElementChild); | |
// get the article description elements, then map to get the textConent of those elements |
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
((d, w) => { | |
// select the static HTML element that all this DOM manipulation will be contained to | |
let widget = d.getElementById("medium-widget"); | |
const mainImgObserver = new MutationObserver(() => { | |
// if these elements have been rendered in the DOM | |
if (widget.getElementsByClassName("medium-widget-article__image").length > 0) { | |
// get the <a> link elements from the DOM, then map to get the child <img> elements | |
console.log(widget.getElementsByClassName("medium-widget-article__image")) | |
// stop observing |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- title and description --> | |
<meta name="description" content="Nikolas Osvalds personal web development portfolio website"> | |
<title>Nik Osvalds - Home</title> | |
<meta property="og:image" content="https://www.nikolaso.com/images/photos/thumbnail.jpeg"/> | |
<!-- custom JS --> | |
<script defer src="./js/scripts.js"></script> |
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
const Responses = { | |
_200(data = {}){ | |
return { | |
headers: { | |
'Content-Type': 'application/json', | |
'Access-Control-Allow-Methods': '*', | |
'Access-Control-Allow-Origin': '*', | |
}, | |
statusCode: 200, | |
body: JSON.stringify(data) |
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
// Auth password routes | |
app.post(`/auth/forgot-password`, AuthController.forgotPassword); | |
app.post(`/auth/reset-password`, AuthController.resetPassword); | |
app.post(`/auth/update-password`, passport.authenticate('jwt', { session: false }), AuthController.updatePassword) |
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
const table = process.env.USERS_TABLE; | |
const fs = require('fs'); | |
const fsPromises = fs.promises; | |
const Handlebars = require("handlebars"); | |
// AWS | |
const AWS = require('aws-sdk') | |
const dynamodb = new AWS.DynamoDB.DocumentClient(); | |
const ses = new AWS.SES({region: 'us-east-1'}); // Simple email service |
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
{ | |
"email": "<email>", | |
"password": "<password hash>", | |
"password_reset_tokens": { | |
"f7cfb2dbda77e093baf2a078f2ceb8c65965b7382109f23bb4710a9f83ad9c59": { | |
"expiration": "2020-06-30T00:00:00.00Z", | |
"used": true, | |
"created": "2020-06-29T23:00:00.00Z", | |
"updated": "2020-06-29T23:00:00.00Z" | |
}, |
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
/** | |
* Create password reset token using inbuilt crypto | |
*/ | |
const createResetToken = () => { | |
return require('crypto').randomBytes(32).toString('hex') | |
} |
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
const table = process.env.USERS_TABLE; | |
const AWS = require('aws-sdk'); | |
const dynamodb = new AWS.DynamoDB.DocumentClient(); | |
/** | |
* Set a user's existing un-used reset tokens to used | |
* @param {object} user user object | |
*/ | |
const expirePasswordTokens = async (user) => { | |
if (!user) throw new Error(`"user" is required`); |
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
<!-- BEGIN BODY // --> | |
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateBody"> | |
<tr> | |
<td class="bodyContent" style="padding-top:0; padding-bottom:0;"> | |
<img src="https://digitalhumani.com/img/logo-final.png" style="max-width:60px;" id="bodyImage" /> | |
</td> | |
</tr> | |
<tr> | |
<td valign="top" class="bodyContent"> | |
<h1 style="color: #0A8A08 !important;">Password Reset Request</h1> |
OlderNewer