// from the flitter/auth project - middleware/KeyAction.js/** * @module flitter-auth/middleware/KeyAction */const Middleware = require('libflitter/middleware/Middleware')/** * Middleware for processing key actions. * @extends module:libflitter/middleware/Middleware~Middleware */class KeyAction extends Middleware {  /**   * Defines the services required by this middleware.   * @returns {Array<string>}   */  static get services() {    return [...super.services, 'models']  }  /**   * Looks up the key action from the request params' "key"   * property and injects it into the session. If necessary,   * authenticates the user and injects them as well.   *   * Will send a 401 denial if the key action or user are invalid.   *   * @param {express/request} req - the request   * @param {express/response} res - the response   * @param {function} next - the next function in the stack   * @param {*} [args = {}] - optional arguments   * @returns {Promise<void>}   */  async test(req, res, next, args = {}){    const KeyAction = this.models.get('auth:KeyAction')    const lookup_key = req.params.key ? req.params.key : (req.session.key_action_key ? req.session.key_action_key : false)    if ( !lookup_key ) return req.security.deny()    const action = await KeyAction.lookup({ key: lookup_key })    if ( !action ) return req.security.deny()    if ( action.user_id ) {      const user = await action.user()      if ( req.user && String(req.user._id) !== String(user._id) ) return req.security.kickout()      if ( action.auto_login ) {        if ( req.user ) {          action.did_auto_login = false        } else {          const provider = await req.security.provider()          await provider.session(req, user)          action.did_auto_login = true        }      }    }    action.used = true    await action.save()    req.key_action = action// from the flitter/auth project - middleware/KeyAction.js/** * @module flitter-auth/middleware/KeyAction */const Middleware = require('libflitter/middleware/Middleware')/** * Middleware for processing key actions. * @extends module:libflitter/middleware/Middleware~Middleware */class KeyAction extends Middleware {  /**   * Defines the services required by this middleware.   * @returns {Array<string>}   */  static get services() {    return [...super.services, 'models']  }  /**   * Looks up the key action from the request params' "key"   * property and injects it into the session. If necessary,   * authenticates the user and injects them as well.   *   * Will send a 401 denial if the key action or user are invalid.   *   * @param {express/request} req - the request   * @param {express/response} res - the response   * @param {function} next - the next function in the stack   * @param {*} [args = {}] - optional arguments   * @returns {Promise<void>}   */  async test(req, res, next, args = {}){    const KeyAction = this.models.get('auth:KeyAction')    const lookup_key = req.params.key ? req.params.key : (req.session.key_action_key ? req.session.key_action_key : false)    if ( !lookup_key ) return req.security.deny()    const action = await KeyAction.lookup({ key: lookup_key })    if ( !action ) return req.security.deny()    if ( action.user_id ) {      const user = await action.user()      if ( req.user && String(req.user._id) !== String(user._id) ) return req.security.kickout()      if ( action.auto_login ) {        if ( req.user ) {          action.did_auto_login = false        } else {          const provider = await req.security.provider()          await provider.session(req, user)          action.did_auto_login = true        }      }    }    action.used = true    await action.save()    req.key_action = action// from the flitter/auth project - middleware/KeyAction.js/** * @module flitter-auth/middleware/KeyAction */const Middleware = require('libflitter/middleware/Middleware')/** * Middleware for processing key actions. * @extends module:libflitter/middleware/Middleware~Middleware */class KeyAction extends Middleware {  /**   * Defines the services required by this middleware.   * @returns {Array<string>}   */  static get services() {    return [...super.services, 'models']  }  /**   * Looks up the key action from the request params' "key"   * property and injects it into the session. If necessary,   * authenticates the user and injects them as well.   *   * Will send a 401 denial if the key action or user are invalid.   *   * @param {express/request} req - the request   * @param {express/response} res - the response   * @param {function} next - the next function in the stack   * @param {*} [args = {}] - optional arguments   * @returns {Promise<void>}   */  async test(req, res, next, args = {}){    const KeyAction = this.models.get('auth:KeyAction')    const lookup_key = req.params.key ? req.params.key : (req.session.key_action_key ? req.session.key_action_key : false)    if ( !lookup_key ) return req.security.deny()    const action = await KeyAction.lookup({ key: lookup_key })    if ( !action ) return req.security.deny()    if ( action.user_id ) {      const user = await action.user()      if ( req.user && String(req.user._id) !== String(user._id) ) return req.security.kickout()      if ( action.auto_login ) {        if ( req.user ) {          action.did_auto_login = false        } else {          const provider = await req.security.provider()          await provider.session(req, user)          action.did_auto_login = true        }      }    }    action.used = true    await action.save()    req.key_action = action

Hi, there.

My name is Garrett.

I'm a speaker, developer, and designer.

Hi, there.

My name is Garrett.

I'm a speaker, developer, and designer.

about me

Hi! My name is Garrett. Welcome to my little corner of the internet. I'm a self-taught developer and tech-nerd. I create software that I hope makes people's lives better. I created the Flitter web framework, and a couple other fun projects. I love to communicate my work, and help others pursue their projects, which is why I've got a long history of sharing about my passion. I write blog posts, create video tutorials, hold talks, and publish code from my projects in the hope that others will find it useful.

A bit more background: I grew up in the rural mid-west, so I taught myself everything I know. I'm a big fan of learning to code this way. I'm currently studying computer science at the University of Kansas.

about me

Hi! My name is Garrett. Welcome to my little corner of the internet. I'm a self-taught developer and tech-nerd. I create software that I hope makes people's lives better. I created the Flitter web framework, and a couple other fun projects. I love to communicate my work, and help others pursue their projects, which is why I've got a long history of sharing about my passion. I write blog posts, create video tutorials, hold talks, and publish code from my projects in the hope that others will find it useful.

A bit more background: I grew up in the rural mid-west, so I taught myself everything I know. I'm a big fan of learning to code this way. I'm currently studying computer science at the University of Kansas.

get in touch

I'd love to hear from you if you have questions or inquiries related to me or my projects. You can get in touch by text, e-mail, or using this form. I also tweet sometimes, and share thoughts on my blog.

E-Mail: shout@garrettmills.dev
Phone: (913) 730-7124

I'd love to hear from you if you have questions or inquiries related to me or my projects. You can get in touch by text, e-mail, or using this form. I also tweet sometimes, and share thoughts on my blog.

E-Mail: shout@garrettmills.dev
Phone: (913) 730-7124

what I've been up to

Craigslist

Craigslist

Computer Parts for Sale - Lawrence, KS

I recently switched to a Dell XPS 15 as my daily driver. So, I'm parting-out my other machines that I don't use.

If you live in or near Lawrence, KS, and have any interest, I'm offering pretty good prices for a budget gaming rig:

6/30/2020, 10:23:20 AM

Code Release

Code Release

Feed Page, RSS, & Atom - Minor Website Updates I recently made some tweaks to my website. I added a dedicated page as a historical archive for these updates.

I also added the ability to subscribe to this feed using RSS, Atom, and JSON thanks to a handy NPM package.

5/8/2020, 7:30:33 PM

Code Release

Code Release

VuES6 - ES6 Vue.js Components, in Plain JavaScript

I recently released a small utility library for defining Vue components as proper ES6 classes, but in vanilla JavaScript. I like to use this in small projects where I don't want to have to set up vue-cli and compile templates. More info here.

4/22/2020, 6:17:15 PM

Side Project

Side Project

Connect-4 Webtoy

I've built a simple Connect-4 webtoy as a project for EECS 368 at the University of Kansas. You can play with it here.

4/8/2020, 9:20:25 AM

Blog Post

Blog Post

Code Freedom with Gitea & Drone - Part I

In my never-ending quest to self-host all the things, I've deployed a combination of Gitea and Drone CI for a feature-for-feature, self-hosted alternative to GitHub. Here's how.

3/6/2020, 11:10:49 PM

HackKU 2020

HackKU 2020

Noded - Free-Form Notes & Databases

I recently attended the annual University of Kansas hackathon, where me and a couple friends built Noded.

Noded is a tree-based note taking app based on reusable page elements. It provides support for basic notes, uploaded files, a built-in code editor, customizable databases, static website exports, and sub-tree sharing. Check it out here.

2/24/2020, 7:28:06 PM

Garrett Mills
Copyright © 2020 Garrett Mills